maxatwork/form2js — Issue #27: Incorrect handling of ruby-style fields
Author: m4dm4n
Created: 2011-12-08 05:52:09+00:00
State: open

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:

```javascript
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:

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

It seems to work perfectly after adding the extra underscore.