Simple form input type

karp picture karp · Sep 30, 2013 · Viewed 10.1k times · Source

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?

Answer

rorofromfrance picture rorofromfrance · Sep 30, 2013

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 !