[Rails] Params with multiple values
Scott Barron
scott at elitists.net
Wed Jan 12 21:38:05 GMT 2005
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : http://one.textdrive.com/pipermail/rails/attachments/20050112/678ee0b6/signature.bin
More information about the Rails
mailing list