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. The problem is that RAILS is only returning one value in transition.complete_tasks. Any idea what is going on? Thanks! -- Posted via http://www.ruby-forum.com/.
I ended up having to write a small, simple helper for this because I ran into the same problem. Basically the helper takes the same attributes as options_from_col.... does, and also takes an array of selected objects and generates the list accordiningly. I dont have it on me now, but will post it tomorrow if I can and if you need it. -Nick On 1/4/06, Stan Shore <stan@workflowinc.com> 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. > > The problem is that RAILS is only returning one value in > transition.complete_tasks. > > Any idea what is going on? > > Thanks! > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060105/15307394/attachment.html
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 Koziarski in my mail archive: <quote> On Apr 12, 2005 9:47 AM, Jason Foreman <threeve.org@gmail.com> wrote: >>> I''m trying to get multiple selected values from a <SELECT> 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. </quote> That was in a thread with subject "[Rails] Getting multiple values from <SELECT> into @params?", back in April 2005. regards Justin