esmith-eOMzn3TCJv5Wk0Htik3J/w@public.gmane.org
2007-Dec-17 20:38 UTC
Select Multiple - does it work? Help!
I realize that doing a select with multiple must work, yet despite so many attempts following dozens of examples I have yet to get any success. I have the following (example) code: <%= select_tag ''test[]'', options_for_select(["one", "two", "three"], ["one"]), { :multiple => true, :size =>5, :id => "test" } %> Note I have the brackets after test - so Rails knows its an array. When I select one and two in the form I get this: "test"=>["two"] in my log, instead of both entries. What am I doing wrong? This should be a simple task and I''ve been arguing with it all day. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Here is the syntax for multiple-select: <%= select_tag ''categories[]'', options_for_select( @categories ), { :multiple => true, :size => 15, :style => "width:250px" } %> It looks like you don''t need the :id parameter. If you select multiple values, an array with multiple ids will be submitted to the server. On Dec 17, 2007 12:38 PM, esmith-eOMzn3TCJv5Wk0Htik3J/w@public.gmane.org <paytonrules-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I realize that doing a select with multiple must work, yet despite so > many attempts following dozens of examples I have yet to get any > success. I have the following (example) code: > > <%= select_tag ''test[]'', options_for_select(["one", "two", "three"], > ["one"]), { :multiple => true, :size =>5, :id => "test" } %> > > Note I have the brackets after test - so Rails knows its an array. > When I select one and two in the form I get this: > > "test"=>["two"] > > in my log, instead of both entries. What am I doing wrong? This > should be a simple task and I''ve been arguing with it all day. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
esmith-eOMzn3TCJv5Wk0Htik3J/w@public.gmane.org
2007-Dec-17 22:35 UTC
Re: Select Multiple - does it work? Help!
Unfortunately when I do what you''ve got verbatim - I get one parameter (whatever is the last selected one) sent, as an array. On Dec 17, 3:36 pm, "Bala Paranj" <bcpar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Here is the syntax for multiple-select: > > <%= select_tag ''categories[]'', > options_for_select( @categories ), { :multiple => true, > :size => 15, > :style => "width:250px" } > %> > > It looks like you don''t need the :id parameter. If you select multiple > values, an array with multiple ids will be submitted to the server. > > On Dec 17, 2007 12:38 PM, esm...-eOMzn3TCJv5Wk0Htik3J/w@public.gmane.org <paytonru...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I realize that doing a select with multiple must work, yet despite so > > many attempts following dozens of examples I have yet to get any > > success. I have the following (example) code: > > > <%= select_tag ''test[]'', options_for_select(["one", "two", "three"], > > ["one"]), { :multiple => true, :size =>5, :id => "test" } %> > > > Note I have the brackets after test - so Rails knows its an array. > > When I select one and two in the form I get this: > > > "test"=>["two"] > > > in my log, instead of both entries. What am I doing wrong? This > > should be a simple task and I''ve been arguing with it all day.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---