collection_select default value?

Gary Huntress
2007-11-04T17:13:20Z

I''m having some confusion with collection_select().    I am using two
of them on my form:

<%= collection_select(:user, :id, @users, :id, :login) %>
<%= collection_select(:department, :id, @depts, :id, :name, {},
:multiple=>"multiple") %>

If I submit the page without selecting a department in the multiselect
box, I will get a nil object.  This is what I want.

If I submit the page without selecting a user, I do not get a nil user
object.  It is populated with the first item in the select box.   This
is not what I want.   I want to detect that a user has not selected a
name from the list.

Why is the first collection_select() returning a value when the user
has not selected an item?


Thx,

Gary H.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---