I am working on a Rails 2.3.9 application . I need to pass a class to the options. The way i am doing is
<%= select(:resporg, "hresporg_#{row_id}",options_for_select(["Item11",["Item 2", {:class => 'has-versions'}]]), {}, {:multiple => true})%>
Output
<select id="resporg_hresporg_1" name="resporg[hresporg_1][]" multiple="multiple">
<option value="Item11">Item11</option>
<option value="classhas-versions">Item 2</option>
</select>
If you check the above output the class is coming as value. Any idea on what is going wrong?
I have to manually do it because of the constraint. That this is valid for rails >= 3.0.0
In the template.html.erb
<select style="width:160px !important;" id="resporg_hresporg_1" name="resporg[hresporg_1][]" multiple="multiple">
<%= opts %>
</select>
In the helper
def opts
str = ''.html_safe
['Item1','Item2'].each { |val| str << content_tag(:option, val, :value => val,:class => val.eql?('Item2') ? "MyClass" : nil) }
str.html_safe
end