maxatwork / form2js

Javascript library for collecting form data
http://maxatwork.github.com/form2js/
MIT License
640 stars 137 forks source link

Incorrect handling of ruby-style fields #27

Open ghost opened 12 years ago

ghost commented 12 years ago

Unfortunately the lack of comments in processNameValues makes it hard to work out if I'm just mistaken about how this works, but I was experiencing a bug using CakePHP trying to parse ruby-style field names. A checkbox list such as this: data[Topic][topic_id] was causing an error when I tried to parse it. Turns out the problem was the code:

arrIdx = namePart[k].match(/([a-z_]+)?\[([a-z_][a-z0-9]+?)\]/i);

The regexp doesn't allow an underscore in the rest of the name, which doesn't seem right to me. Seems like it should be:

arrIdx = namePart[k].match(/([a-z_]+)?\[([a-z_][a-z0-9_]+?)\]/i);

It seems to work perfectly after adding the extra underscore.

krainboltgreene commented 12 years ago

Looks like this was fixed?