karp
karp

Reputation: 183

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?

Upvotes: 16

Views: 16363

Answers (3)

rorofromfrance
rorofromfrance

Reputation: 1904

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 !

Upvotes: 24

Nicholas Phillips
Nicholas Phillips

Reputation: 129

Simplest method:

f.input :whatever, as: :numeric

Upvotes: 10

Oleg Haidul
Oleg Haidul

Reputation: 3732

Try:

f.input :amount, as: :integer

Upvotes: 4

Related Questions