form2js
form2js copied to clipboard
js2form: bind list of values to multiselect
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);
}