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.
Spyros Vasileiadis (Guest)
on 2006-05-10 16: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
Spyros V. (Guest)
on 2006-05-10 16:43
Actually I just found it. Its

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

strangely though if I take out ",nil" it errors.
Rimantas L. (Guest)
on 2006-05-10 16: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/
Rimantas L. (Guest)
on 2006-05-10 16: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.