Commit 61c69bda 61c69bda24e9cfc4ac39ee9c72f1e6cf554a3de0 by Nicolas Perriault

Merge pull request #20 from cbenz/cbenz

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