Search code examples
ruby-on-railshtmlsimple-form

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?


Solution

  • 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 !