Prototype Form.serialize and mutli selects

Hi,

[I asked this on the rails.spinoff list beginning of the week without an answer. I’m not sure what’s the right place to ask questions about rails and prototype so I’ll try again here.]

I ran into a problem when using a multi select list in a form
submitted through ajax.

The name of the select element is something like foo[].
When multiple entries are selected the browser creates form data like
foo[]=1&foo[]=2&foo[]=4 (url encoded of course).
Rails then creates an array [“1”,“2”,“4”] for foo’s entry in the
parameter hash.

Prototype OTOH creates form data like
foo[]=1,2,4
which isn’t recognized by rails as multiple values and I end up with an
array [“1,2,4”] in the parameter hash, which does not work for updating
a habtm relationship.

Should this be considered a bug in prototype (Form.serialize should work
the same way the browser works)? Or is it a rails problem?

Morus

Hi Morus,

On 12/9/05, Morus W. [email protected] wrote:

Prototype OTOH creates form data like
foo[]=1,2,4
which isn’t recognized by rails as multiple values and I end up with an
array [“1,2,4”] in the parameter hash, which does not work for updating
a habtm relationship.

Should this be considered a bug in prototype (Form.serialize should work
the same way the browser works)? Or is it a rails problem?

I agree, Prototype’s behavior is broken. Expect a corrected version
to ship with Rails 1.0.


sam

Hi Sam,

I agree, Prototype’s behavior is broken. Expect a corrected version
to ship with Rails 1.0.

Great to hear this.

Thanks a lot for your great work on prototype.

Morus