Hi, 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 wrong with it? <select name="job[techs]" size="5" multiple> <%= options_from_collection_for_select(@techs, "id", "full_name", @ job.technician.collect { |t| t.technician_id.to_i }) %> </select> Thanks, Vincent. -- Vincent Foley-Bourgon Blog: http://www.livejournal.com/~gnuvince World.run while (6 * 9 == 42) _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Are you using XHTML? try multiple="multiple" instead of just the single attribute ''multiple.'' On 4/10/05, Vincent Foley <vfoley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > 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 > wrong with it? > > <select name="job[techs]" size="5" multiple> > <%= options_from_collection_for_select(@techs, "id", > "full_name", @job.technician.collect { |t| t.technician_id.to_i }) %> > </select> > > Thanks, > > Vincent. > > -- > Vincent Foley-Bourgon > Blog: http://www.livejournal.com/~gnuvince > World.run while (6 * 9 == 42) > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- rick http://techno-weenie.net
Jordan Running
2005-Apr-11 16:37 UTC
Re: Getting multiple values from <SELECT> into <at> params?
> I''m trying to get multiple selected values from a <SELECT> tag into > <at> params, but I can only get the first value in.In PHP, this would be solved by putting [] at the end of the field name, e.g.: <select name="job[techs][]" size="5" multiple="multiple"> This causes the selected values to be treated as an array. I have a feeling it will be the same for Rails.
Jason Foreman
2005-Apr-11 21:47 UTC
Re: Getting multiple values from <SELECT> into @params?
> > 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, somethingi believe to get multiple value params you use @request.params instead of @params. @params will always only give you the first one. Jason
Michael Koziarski
2005-Apr-11 22:28 UTC
Re: Getting multiple values from <SELECT> into @params?
On Apr 12, 2005 9:47 AM, Jason Foreman <threeve.org-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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.> Jason > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz