Anthony Gardner wrote:
> I'm trying to get a multi select box working with fields_for but am 
> having a
> few problems.
> 
> My view has ....
> 
> <% form_for(@teacher) do |f| %>
>   <%= f.label :surname %>
>   <%= f.text_field :surname %>
> 
>   <% f.fields_for :qualifications do |qual_form| %>
>     Qualifications:  <%= qual_form.select( :id, @qualifications) %>
>   <% end %>
> 
>   <%= f.submit %>
> <% end %>
> 
> Which produces (for the fields_for) ......
> 
> <select id="teacher_qualifications_attributes_0_id"
> name="teacher[qualifications_attributes][0][id]">
>   <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>
[...]
> but what I think I really want is a multi select box with the submitted 
> data
> looking something like ......
> "teacher"=>{"qualifications_attributes"=>{"id"=>["2","3","4"]}},
> "surname"=>""}}
> 
> Could somebody putme out of my misery, please?

Do you know how to make a multiple select in HTML?  You just use <select 
multiple="multiple">.  So in Rails, you'd put :multiple => true in the 
html_options for your select helper.  Simple.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
> 
> TIA

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to