Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails form text field helper, how to make the input area wider?

How do 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?

like image 936
Blankman Avatar asked Dec 16 '10 04:12

Blankman


4 Answers

You can also do something like:

    <%= f.text_area :description, :cols => "10", :rows => "10" %>
like image 93
Mark Locklear Avatar answered Oct 31 '22 11:10

Mark Locklear


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)

like image 26
Jimmy Huang Avatar answered Oct 31 '22 09:10

Jimmy Huang


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

like image 3
ssri Avatar answered Oct 31 '22 11:10

ssri


You can do it by simply using rows option in your text field. Like

<%= f.text_area :fieldname, :rows => "10" %>
like image 1
Jyothu Avatar answered Oct 31 '22 11:10

Jyothu