Forum: Ruby on Rails text_field_tag options

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B1cb30b86898d7f51fb1b56b1de332c1?d=identicon&s=25 Spyros Vasileiadis (Guest)
on 2006-05-10 14:30
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
B1cb30b86898d7f51fb1b56b1de332c1?d=identicon&s=25 Spyros Vasileiadis (kleas)
on 2006-05-10 14:43
Actually I just found it. Its

<%= text_field_tag :query, nil, :size => 5     %>

strangely though if I take out ",nil" it errors.
Ec5a599777854c540fd102ef4691fe10?d=identicon&s=25 Rimantas Liubertas (Guest)
on 2006-05-10 14:46
(Received via mailing list)
<...>
> 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/
Ec5a599777854c540fd102ef4691fe10?d=identicon&s=25 Rimantas Liubertas (Guest)
on 2006-05-10 14:52
(Received via mailing list)
<...>
> <%= 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/
This topic is locked and can not be replied to.