form2js icon indicating copy to clipboard operation
form2js copied to clipboard

js2form: bind list of values to multiselect

Open Pavel-Nosov opened this issue 10 years ago • 0 comments

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);
      }

Pavel-Nosov avatar Feb 02 '15 14:02 Pavel-Nosov