Search code examples
ruby-on-railssimple-form

change size and maxlength allowed for a field in simple_form


How can I change the size and max allowed characters for a field using Simple Forms. I've tried following but does not work:

<%= f.input :lastname, :size => 40, :max => 4 %>

I know there is a default_input_size in initializers/simple_form.rb however, I don't want to change the size globally but just on few fields.

How would I do this?


Solution

  • <%= f.input :lastname, input_html: { maxlength: 15, size: 40} %>