Forum: Ruby on Rails html_options and select()

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.
2ea40766e41f97c620cefc388636414d?d=identicon&s=25 Chris Mcdevitt (cmcdevitt)
on 2006-06-01 20:27
I am trying to add html_options to select():
<%=select(:user, :id,[['me',1],['myself',2],['and I',3]], :select =>
{},:html_options => {"size" => 5, "multiple" => true})%>

This does not work...  How do I get the html_options to work?


ActionView::Helpers::FormOptionsHelper
9ab183bb240ffd3a3966d5a615b4bdeb?d=identicon&s=25 Philip Ross (Guest)
on 2006-06-02 00:19
(Received via mailing list)
Chris McDevitt wrote:
> I am trying to add html_options to select():
> <%=select(:user, :id,[['me',1],['myself',2],['and I',3]], :select =>
> {},:html_options => {"size" => 5, "multiple" => true})%>
>
> This does not work...  How do I get the html_options to work?

Try the following:

<%=select(:user, :id,[['me',1],['myself',2],['and I',3]], {},
{"size" => 5, "multiple" => true})%>

options and html_options are two separate hash parameters. The syntax
you were using would have passed the following hash as options and left
html_options empty:

{:select=>{}, :html_options=>{"size"=>5, "multiple"=>true}}

--
Philip Ross
http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby
2ea40766e41f97c620cefc388636414d?d=identicon&s=25 Chris Mcdevitt (cmcdevitt)
on 2006-06-02 17:30
Philip Ross wrote:

> <%=select(:user, :id,[['me',1],['myself',2],['and I',3]], {},
> {"size" => 5, "multiple" => true})%>
>
> options and html_options are two separate hash parameters. The syntax
> you were using would have passed the following hash as options and left
> html_options empty:
>
> {:select=>{}, :html_options=>{"size"=>5, "multiple"=>true}}
>
> --
> Philip Ross
> http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby

Thank you.  That worked.
9c3ca68871c5e2218e8e4a0d73f6b684?d=identicon&s=25 Rajat Garg (rajatgarg)
on 2008-12-19 01:19
Thanks. This saved me today :(
This topic is locked and can not be replied to.