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.
Chris M. (Guest)
on 2006-06-01 22: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
Philip R. (Guest)
on 2006-06-02 02: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 R.
http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby
Chris M. (Guest)
on 2006-06-02 19:30
Philip R. 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 R.
> http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby

Thank you.  That worked.
Rajat G. (Guest)
on 2008-12-19 02:19
Thanks. This saved me today :(
This topic is locked and can not be replied to.