Html_options and select()


#1

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


#2

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


#3

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.


#4

Thanks. This saved me today :frowning: