form2js icon indicating copy to clipboard operation
form2js copied to clipboard

Seeing error on line 146 of form2object.js

Open osxboy opened this issue 14 years ago • 2 comments

I'm seeing the error:

currResult[arrName].push is not a function

When processing a form that has dynamically generated fields, do you have any ideas why?

TIA

osxboy avatar Oct 20 '11 13:10 osxboy

Can you provide a form which generates this error?

maxatwork avatar Nov 13 '11 09:11 maxatwork

The problem occurs when you have following scenario: A form where you can form lines dynamically and one of the elements in the line is a select element with a name like "name[]". The name will become "name" in the line where there is a select element. If you add another line after this without a select element, but a normal element with the name "name[]", the name will stay "name[]" and it will try to push to currResult[name] which once was an array and then was replaced by the value which was selected in the selectbox...

The problem is caused by the replacement of square brackets in the name of a select element. line 250: result = [ { name: fieldName.replace(/[]$/, ''), value: fieldValue } ] possible fix (possibly breaks other code???): result = [ { name: fieldName, value: fieldValue } ]

Malkaduhimi avatar May 31 '12 13:05 Malkaduhimi