maxatwork / form2js

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

js2form: bind list of values to multiselect #77

Open Pavel-Nosov opened 9 years ago

Pavel-Nosov commented 9 years ago

js2form: list of values doesn't bind to multiselect. Example: I need to map object:

var x = {
    levels : ["DEBUG, ""INFO"]
};
js2form(form, x);

to the form with the control:

<select id="levels" name="levels" multiple="multiple"/>

It seems to me that js2form required select name "levels[]", but it's not correct fully. The fix could look like addition another last "if" branch to the js2form function, I suppose:

      else if (typeof formFieldsByName[fieldName.replace(_arrayItemRegexp, '')] != 'undefined')
      {
        setValue(formFieldsByName[fieldName.replace(_arrayItemRegexp, '')], fieldValue);
      }