Fixed selection of multiple optional packages
authorAlexander Ebert <ebert@woltlab.com>
Tue, 14 May 2013 22:47:26 +0000 (00:47 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 14 May 2013 22:47:26 +0000 (00:47 +0200)
wcfsetup/install/files/acp/js/WCF.ACP.js
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php

index e4522d6f67c909b09f15ae78dc7fffe30bdadb97..04f3d7cee090c864bdc86e0165d21d6085b303ec 100644 (file)
@@ -579,7 +579,30 @@ WCF.ACP.Package.Installation = Class.extend({
                                return false;
                        }
                        
-                       $additionalData[$inputElement.attr('name')] = $inputElement.val();
+                       var $name = $inputElement.attr('name');
+                       if ($name.match(/(.*)\[([^[]*)\]$/)) {
+                               $name = RegExp.$1;
+                               $key = RegExp.$2;
+                               
+                               if ($additionalData[$name] === undefined) {
+                                       if ($key) {
+                                               $additionalData[$name] = { };
+                                       }
+                                       else {
+                                               $additionalData[$name] = [ ];
+                                       }
+                               }
+                               
+                               if ($key) {
+                                       $additionalData[$key] = $inputElement.val();
+                               }
+                               else {
+                                       $additionalData[$key].push($inputElement.val());
+                               }
+                       }
+                       else {
+                               $additionalData[$name] = $inputElement.val();
+                       }
                });
                
                this._executeStep(data.step, data.node, $additionalData);
index 532c23453ffb7df3e49e3c480dd4f9d3700e2cae..23621d1632ca096dcfc35e5410da5cc5b3994abc 100644 (file)
@@ -646,7 +646,7 @@ class PackageInstallationDispatcher {
                        
                        foreach ($packages as $package) {
                                $optionalPackage = new MultipleSelectionFormElement($container);
-                               $optionalPackage->setName('optionalPackages');
+                               $optionalPackage->setName('optionalPackages[]');
                                $optionalPackage->setLabel($package['packageName']);
                                $optionalPackage->setValue($package['package']);