dotjake
2007-Jun-27 20:15 UTC
Collection_select does not return empty array if no options selected
Hello,
I have two separate category collection_selects for two separate
models each with a habtm relationship to categories. With the update
form for one model, de-selecting all of the options submits a
parameter such as category_ids => [""]. In the other, de-selecting
the
options returns no parameter, and as a result the join table is not
updated.
The collection_selects look like this:
<%= form.collection_select(:category_ids, @categories, :id, :name, {},
{:multiple => true, :size => 5}) %>
I can overcome the problem by adding :include_blank => true to the
options, but this is not an intuitive solution and it is absolutely
unclear to me why this problem would occur in one model and not
another. The only difference between the forms is that the one which
works properly, returning an empty array, is submitted via
remote_form_for, not form_for.
Thanks in advance
Jake
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---