# Prototype Form.serialize and mutli selects

**URL:** <https://www.ruby-forum.com/t/prototype-form-serialize-and-mutli-selects/49851>\
**Category:** Rails\
**Created:** [December 9, 2005, 8:17am UTC](https://www.ruby-forum.com/t/prototype-form-serialize-and-mutli-selects/49851 "2005-12-09T08:17:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![morus.walter.ml](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@morus.walter.ml](https://www.ruby-forum.com/u/morus.walter.ml)\
**Post date:** [December 9, 2005, 8:17am UTC](https://www.ruby-forum.com/t/prototype-form-serialize-and-mutli-selects/49851/1 "2005-12-09T08:17:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![morus.walter.ml](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@morus.walter.ml](https://www.ruby-forum.com/u/morus.walter.ml)\
**Post date:** [December 9, 2005, 8:46am UTC](https://www.ruby-forum.com/t/prototype-form-serialize-and-mutli-selects/49851/2 "2005-12-09T08:46:04Z")

</div>

Hi Morus,

On 12/9/05, Morus W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![morus.walter.ml](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@morus.walter.ml](https://www.ruby-forum.com/u/morus.walter.ml)\
**Post date:** [December 9, 2005, 9:18am UTC](https://www.ruby-forum.com/t/prototype-form-serialize-and-mutli-selects/49851/3 "2005-12-09T09:18:55Z")

</div>

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
