Using Rails 2, I have multiple objects in a form and am using fields_for. My problem is creating a multi select and sending that off to the controller as a hash.
In my erb, I have …
<% teacher.fields_for :qualifications do |qual_form| %> <%= qual_form.select , @qualifications, { :multiple => true, :size => 5, :disabled => false } %>
which produces a non-multi select …
<select id="teacher_qualifications_" name="teacher[qualifications][]">
<option value="5">Licence</option>
<option value="1">NPLQ</option>
<option value="3">Teacher's Level One</option>
<option value="4">Teacher's Level Two</option>
<option value="2">Teacher's Rescue Test</option>
</select>
which sends “qualifications”=>[“5”] to the controller and not qualifications"=> { [“5”] }
The HTML produced looks almost right but isn’t. I can send a hash of information with a <%= qual_form.text_field :id %> for example but I need a select.
I’ve tried select_tag and although I’m able to get a multi select going on, I still can’t send a hash.
<%= select_tag “teacher[qualifications]”, options_for_select( @qualifications, @selected_qualifications ),
{ :multiple => true, :size => 5, :disabled => false, :id => "qualifications" } %>
Can someone help me, please.
Thank you