form2js icon indicating copy to clipboard operation
form2js copied to clipboard

Issue when using js2form

Open pnomolos opened this issue 13 years ago • 1 comments

I have my form names in ruby-style syntax like a[b][c], but when using js2form the normalizeName process turns the object I pass into the a.b.c style names. This means that the input names to don't match the names the js2form function is creating for the object, so nothing gets filled in. Is this the intended behavior or am I missing something?

pnomolos avatar Nov 28 '12 04:11 pnomolos

As a followup, this only occurs when you have ruby-style syntax one level deep (such as a[b]). I fixed this by adding the following code on lines 136-140 of form2js.js:

else if (/^\w+\[[a-z_][a-z0-9_]+?/.test(namePart))
{
    namePart = namePart[0].split('[', 2);
    nameParts.push(namePart[0], namePart[1].substr(0, namePart[1].length - 1));
}

pnomolos avatar Nov 28 '12 16:11 pnomolos