Fixed handling of 'checkboxes' option type
authorAlexander Ebert <ebert@woltlab.com>
Fri, 16 Oct 2015 12:10:54 +0000 (14:10 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 16 Oct 2015 12:10:54 +0000 (14:10 +0200)
wcfsetup/install/files/js/WCF.User.js

index 278c65cd5876d1470122a6aff7cbd59d719fed33..f99c3a9ccaec85d018c7a20b29f70ffea80afaee 100644 (file)
@@ -1183,7 +1183,20 @@ WCF.User.Profile.Editor = Class.extend({
                        
                        var $name = $element.attr('name');
                        if ($regExp.test($name)) {
-                               $values[RegExp.$1] = ($value === null) ? $element.val() : $value;
+                               var $fieldName = RegExp.$1;
+                               if ($value === null) $value = $element.val();
+                               
+                               // check for checkboxes
+                               if (/\[\]$/.test($name)) {
+                                       if (!Array.isArray($values[$fieldName])) {
+                                               $values[$fieldName] = [];
+                                       }
+                                       
+                                       $values[$fieldName].push($value);
+                               }
+                               else {
+                                       $values[$fieldName] = $value;
+                               }
                        }
                });