Rails form text field helper, how to make the input area wider?
How do 开发者_JAVA技巧I make the text field area wider?
I tried:
f.text_field :title, size => 150
I also tried width, I am missing something here, what is it?
I think it should be
f.text_field :title, :size => 150
Or, you can add :class option and use css to define the size (I prefer)
You can also do something like:
<%= f.text_area :description, :cols => "10", :rows => "10" %>
Are you using the same in your code. I think you are missing a colon before the size.
<%= f.text_field :title, :size => 150 %>
or you can use
<%= f.text_field :title, "size" => 150 %>
size is an undefined local variable whereas :size and "size" are passed as options to the text field form helper
You can do it by simply using rows option in your text field. Like
<%= f.text_area :fieldname, :rows => "10" %>
Size should work, could you post a chunk of code?
FormHelper Documentation
You can always specify a class using the class symbol and specify a width using CSS
<%=text_field_tag 'some_input', nil, :class => 'some-class'%>
Try this for the input field
<%= f.input :content, as: :text, input_html: { rows: "2" } %>
精彩评论