Closed ndelargy closed 13 years ago
This solution will have impact on non-select based arrays serialization (like several text inputs with the same name ending with "[]"). Changed form data extraction function for selects instead.
Have double checked that the solution works for my application. Awesome work. Thanks again.
form2js is excellent, searched for this solution for hours and I'm so glad that I didn't have to attempt to write a solution.
I have a multi select marked up as follows
if we have selected News and Events then formTo produces the following object from this... { ... "categories" : [ [ "News", "Events" ] ] ... }
Whereas I required { ... "categories" : [ "News", "Events" ] ... }
I solved the issue for my own needs by changing line 92 in form2object.js from name = nameValues[i].name; to name = nameValues[i].name.replace('[]','');
This doesn't seem to have any negative effects
I'm using Zend Form to create the form which adds the square brackets to the name if the element is expecting an array