Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple form input type

I am using simple-form gem to render my forms. I am trying to set the input field type to 'number'. This code is not working:

f.input :amount, input_html: { type: 'number' }

What is the proper way to set this up?

like image 842
karp Avatar asked Sep 30 '13 08:09

karp


2 Answers

The following should work

f.input :amount, input_html: { type: 'number' }

An even cleaner way would be:

f.input :amount, as: :numeric

Hope it helps !

like image 175
rorofromfrance Avatar answered Oct 14 '22 05:10

rorofromfrance


Simplest method:

f.input :whatever, as: :numeric
like image 10
Nicholas Phillips Avatar answered Oct 14 '22 05:10

Nicholas Phillips