Problem: I would like to limit input characters for description field. I have done similar function to phone number, but I can't do the same for description field.
My code:
This code works:
f.input :phone_number, :input_html => { :class => 'autogrow', :rows => 1, :cols => 2, :maxlength => 8 }
This code doesn't work:
f.input :description, :input_html => {:class => 'autogrow', :rows => 10, :cols => 10, :maxlength => 200 }
f.input :description_ru, :input_html => {:class => 'autogrow', :rows => 10, :cols => 10, :maxlength => 200 }
Maybe maxlength works just for string type fields ? Because maxlength works for phone number (string datatype) and doesn't work for description and description_ru (both are text datatype in database).
Thank you in advance!
Yes, I think you're right that it works just for string type fields.
This seems to work:
f.input :myfield, as: :string, input_html: { maxlength: 50 }
I just had this problem with a :text
field, switching to :string
solved the issue for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With