Commit af1e3dc0 af1e3dc054b8e42fce96ebe3d9cc5a94e093998e by Christophe Benz

Handle multiple values for checkboxes.

1 parent 4dd4b736
Showing 1 changed file with 15 additions and 1 deletions
...@@ -1186,7 +1186,21 @@ ...@@ -1186,7 +1186,21 @@
1186 field.value = value; 1186 field.value = value;
1187 break; 1187 break;
1188 case "checkbox": 1188 case "checkbox":
1189 field.setAttribute('checked', value ? "checked" : ""); 1189 if (fields) {
1190 var values = value;
1191 if (!Array.isArray(values)) {
1192 values = [values];
1193 }
1194 Array.prototype.forEach.call(fields, function(e) {
1195 if (values.indexOf(e.value) !== -1) {
1196 e.setAttribute('checked', 'checked');
1197 } else {
1198 e.removeAttribute('checked');
1199 }
1200 });
1201 } else {
1202 field.setAttribute('checked', value ? "checked" : "");
1203 }
1190 break; 1204 break;
1191 case "file": 1205 case "file":
1192 throw { 1206 throw {
......