I'm switching my application over to use simple_form
but I'm a little confused about how to display a text input. For instance when I do the following:
f.input :foobar # <textarea name = "model[foobar]"></textarea>
I get a textarea instead instead in input w/ a type of text. How can I force simple_form to output a text input?
it's happening because the field is a text
column in the database, rather than string
/varchar
/etc., you can override the default like so:
f.input :foobar, :as => :string
You can read about all the mappings in the simple_form readme under "Mappings/Inputs available".
I will update the answer to this question, because the new way to do that with simple_form is like this:
f.input :foobar, as: :text
As you can see, using the "as: :text" will use a text_area field, but if you want to modify the amount of rows and cols you should do it like this:
f.input :foobar, as: :text, input_html: {rows: 10, cols: 10}
Here you can see the documentation for the gem:
https://github.com/plataformatec/simple_form
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