Stan Shore wrote:
I am trying to allow the user to select more than one value from a
selection list. Here is the code:
<%= collection_select(:transition, :complete_tasks, @permissions, :id,
:path, “”, {:size => “10”, :multiple => true} ) %>
The multiple HTML option is supposed to allow multiple selections and,
in fact, it does, although the HTML generated show the attribute as
multiple=multiple when it should be just multiple.
multiple=“multiple”
is the correct XHTML (in XHTML, all attributes have to have values)
The problem is that RAILS is only returning one value in
transition.complete_tasks.
Any idea what is going on?
I found this message from Michael K. in my mail archive:
On Apr 12, 2005 9:47 AM, Jason F. wrote:
>>> I'm trying to get multiple selected values from a tag into
>>> @params, but I can only get the first value in. This my code,
something
>
> i believe to get multiple value params you use @request.params
instead
> of @params. @params will always only give you the first one.
No need to do that. Just call your parameter something with [] on the
end. That way rails knows it’s multiple.
i.e if you call it blah[] then @params[“blah”] yields an Array.
That was in a thread with subject “[Rails] Getting multiple values from
into @params?”, back in April 2005.
regards
Justin