# Text\_field\_tag options

**URL:** <https://www.ruby-forum.com/t/text-field-tag-options/60122>\
**Category:** Rails\
**Created:** [May 10, 2006, 2:30pm UTC](https://www.ruby-forum.com/t/text-field-tag-options/60122 "2006-05-10T14:30:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spyros\_Vasileiadis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@Spyros\_Vasileiadis](https://www.ruby-forum.com/u/Spyros_Vasileiadis)\
**Post date:** [May 10, 2006, 2:30pm UTC](https://www.ruby-forum.com/t/text-field-tag-options/60122/1 "2006-05-10T14:30:53Z")

</div>

Hi all,  
can someone explain to me how the options for helper text\_field\_tag  
supposed to be written. I really tried a bunch of stuff without success.

For example I need a field with id “query”, so I write  
\<%= text\_field\_tag :query %\>  
which works fine.

But what if I want the field only 5 characters big? I tried among other  
\<%= text\_field\_tag :query , options=\>{:size=5} %\>  
which doesnt work.  
Any clues?

thanks,  
Kleas

---

<div class="post-metadata">

**Author:** ![Spyros\_Vasileiadis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@Spyros\_Vasileiadis](https://www.ruby-forum.com/u/Spyros_Vasileiadis)\
**Post date:** [May 10, 2006, 2:43pm UTC](https://www.ruby-forum.com/t/text-field-tag-options/60122/2 "2006-05-10T14:43:30Z")

</div>

Actually I just found it. Its

\<%= text\_field\_tag :query, nil, :size =\> 5 %\>

strangely though if I take out “,nil” it errors.

---

<div class="post-metadata">

**Author:** ![Spyros\_Vasileiadis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@Spyros\_Vasileiadis](https://www.ruby-forum.com/u/Spyros_Vasileiadis)\
**Post date:** [May 10, 2006, 2:46pm UTC](https://www.ruby-forum.com/t/text-field-tag-options/60122/3 "2006-05-10T14:46:02Z")

</div>

\<…\>

> But what if I want the field only 5 characters big? I tried among other  
> \<%= text\_field\_tag :query , options=\>{:size=5} %\>  
> which doesnt work.  
> Any clues?

\<%= text\_field\_tag :query, nil, :size =\> 5 %\>

## Regards, Rimantas

[http://rimantas.com/](http://rimantas.com/)

---

<div class="post-metadata">

**Author:** ![Spyros\_Vasileiadis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@Spyros\_Vasileiadis](https://www.ruby-forum.com/u/Spyros_Vasileiadis)\
**Post date:** [May 10, 2006, 2:52pm UTC](https://www.ruby-forum.com/t/text-field-tag-options/60122/4 "2006-05-10T14:52:24Z")

</div>

\<…\>

> \<%= text\_field\_tag :query, nil, :size =\> 5 %\>

There is nothing strange in that.

Syntax is text\_field\_tag(name, value = nil, options = {})

so it expects value as the second parameter. Until named parameters  
are supported you cannot have third parameters without specifying  
second .

## Regards, Rimantas

[http://rimantas.com/](http://rimantas.com/)
