Forum: Ruby on Rails Prototype Form.serialize and mutli selects

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8de11f47e38b4ca190aa80706f7f4f52?d=identicon&s=25 morus.walter.ml (Guest)
on 2005-12-09 08:17
(Received via mailing list)
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
5b9fe87ec1faa67a4599782930f45ec9?d=identicon&s=25 sstephenson (Guest)
on 2005-12-09 08:46
(Received via mailing list)
Hi Morus,

On 12/9/05, Morus Walter <morus.walter.ml@googlemail.com> 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
8de11f47e38b4ca190aa80706f7f4f52?d=identicon&s=25 morus.walter.ml (Guest)
on 2005-12-09 09:18
(Received via mailing list)
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
This topic is locked and can not be replied to.