I have a form which contains two checkboxes with the same name. So: <input type="checkbox" name="foo" value="bar"/> <input type="checkbox" name="foo" value="baz"/> When the form submits I attempt to read the values from the submit like @params[''foo''] Only one value is returned even though both are checked. I looked up the documentation in the CGI module and it appears that I should be getting an array of all values back. Am I missing something here? I know Rails does some modifications on CGI to support multi-level parameter names (i.e. @params[car][color]) but it seems that multiple values should still work. Thanks for any pointers. Eric _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Eric Anderson wrote:> I have a form which contains two checkboxes with the same name. So: > > <input type="checkbox" name="foo" value="bar"/> > <input type="checkbox" name="foo" value="baz"/> > > When the form submits I attempt to read the values from the submit like > > @params[''foo''] > > Only one value is returned even though both are checked. I looked up the > documentation in the CGI module and it appears that I should be getting > an array of all values back. Am I missing something here? I know Rails > does some modifications on CGI to support multi-level parameter names > (i.e. @params[car][color]) but it seems that multiple values should > still work. > > Thanks for any pointers. > > Eric >Eric, Name them "foo[]" to get an array of values back. -Scott _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Scott Barron wrote:> Name them "foo[]" to get an array of values back.Works wonderfully! Thanks! Eric _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I wish I knew this before!! ;-) I had to work around this issue with some JavaScript, but now I see it didnt need to be that way. Eric Anderson wrote:> Scott Barron wrote: > >> Name them "foo[]" to get an array of values back. > > > Works wonderfully! Thanks! > > Eric > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > >