maxatwork / form2js

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

error when traversing back a nested level namespace #39

Open ghost opened 12 years ago

ghost commented 12 years ago

this will fail if you traverse back a level in the array:

 <form id="tests">
     <input name="something[something][title]" value="test"/>
     <textarea name="something[description]">Test</textarea>
 </form>

$('#tests').toObject();

Result:

Uncaught TypeError: Object # has no method 'push'

and to reorder so not traversing back results in an unexpected object:

<form id="tests">
    <textarea name="something[description]">Test</textarea>
    <input name="something[something][title]" value="test"/>
</form>

$('#tests').toObject();

Result:

something:
    0: "Test"
    something:
        title: "test"

Expected result for both cases:

something:
    description: "Test"
    something:
        title: "test"