Support setting up form field depdencies with field id only
authorMatthias Schmidt <gravatronics@live.com>
Thu, 11 Jul 2019 12:46:24 +0000 (14:46 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 11 Jul 2019 12:46:24 +0000 (14:46 +0200)
The actual field will be added when the form is built. This approach makes it easier to set up dependencies at the same time when creating the form field object.

14 files changed:
wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php
wcfsetup/install/files/lib/system/form/builder/field/dependency/AbstractFormFieldDependency.class.php
wcfsetup/install/files/lib/system/form/builder/field/dependency/IFormFieldDependency.class.php
wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/MenuItemPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php

index 0a4872a80592db15a74c986a09268eb41cf74d8a..9f9975d04831166936c3df077aad0ef5e1fb711a 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\system\form\builder;
 use wcf\system\form\builder\field\dependency\IFormFieldDependency;
+use wcf\system\form\builder\field\IFormField;
 
 /**
  * Provides default implementations of `IFormNode` methods.
@@ -391,6 +392,23 @@ trait TFormNode {
                
                $this->isPopulated = true;
                
+               // add dependent fields
+               foreach ($this->getDependencies() as $dependency) {
+                       if ($dependency->getField() === null) {
+                               if ($dependency->getFieldId() === null) {
+                                       throw new \UnexpectedValueException("Dependency '{$dependency->getId()}' for node '{$this->getId()}' has no field.");
+                               }
+                               
+                               /** @var IFormField $field */
+                               $field = $this->getDocument()->getNodeById($dependency->getFieldId());
+                               if ($field === null) {
+                                       throw new \UnexpectedValueException("Unknown field with id '{$dependency->getFieldId()}' for dependency '{$dependency->getId()}'.");
+                               }
+                               
+                               $dependency->field($field);
+                       }
+               }
+               
                return $this;
        }
        
index d563b939ec134a84e02b7d86afd5ad6c6cd9788c..f806071b9afdd9bc8475aeb3a4d880f8f828551b 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\system\form\builder\field\dependency;
+use http\Exception\BadMethodCallException;
 use wcf\system\form\builder\field\IFormField;
 use wcf\system\form\builder\IFormNode;
 use wcf\system\WCF;
@@ -26,6 +27,12 @@ abstract class AbstractFormFieldDependency implements IFormFieldDependency {
         */
        protected $field;
        
+       /**
+        * id of the field the availability of the node dependents on
+        * @var string
+        */
+       protected $fieldId;
+       
        /**
         * id of the dependency
         * @var string
@@ -56,6 +63,19 @@ abstract class AbstractFormFieldDependency implements IFormFieldDependency {
                return $this;
        }
        
+       /**
+        * @inheritDoc
+        */
+       public function fieldId($fieldId) {
+               if ($this->getField() !== null) {
+                       throw new \BadMethodCallException("Cannot set field id after field has been set.");
+               }
+               
+               $this->fieldId = $fieldId;
+               
+               return $this;
+       }
+       
        /**
         * @inheritDoc
         */
@@ -71,11 +91,22 @@ abstract class AbstractFormFieldDependency implements IFormFieldDependency {
         * @inheritDoc
         */
        public function getField() {
-               if ($this->field === null) {
-                       throw new \BadMethodCallException("Field has not been set.");
+               return $this->field;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function getFieldId() {
+               if ($this->getField() !== null) {
+                       return $this->getField()->getId();
                }
                
-               return $this->field;
+               if ($this->fieldId === null) {
+                       throw new \BadMethodCallException("Neither the field nor the field id has been set.");
+               }
+               
+               return $this->fieldId;
        }
        
        /**
index 48abcdc7c5c9bb4b0322f81ea9a78e035f2f60bd..d731bd4240eaa5e2a18b43517581019752fea953 100644 (file)
@@ -41,6 +41,19 @@ interface IFormFieldDependency {
         */
        public function field(IFormField $field);
        
+       /**
+        * Sets the id of the field the availability of the node dependents on.
+        * 
+        * This method should only be used before building the form as afterwards,
+        * the actual field is no automatically set.
+        * 
+        * @param       string          $fieldId        field id
+        * @return      static                          this dependency
+        * 
+        * @throws      \BadMethodCallException         if the field has already been set
+        */
+       public function fieldId($fieldId);
+       
        /**
         * Returns the node whose availability depends on the value of a field.
         * 
@@ -49,12 +62,21 @@ interface IFormFieldDependency {
        public function getDependentNode();
        
        /**
-        * Returns the field the availability of the element dependents on.
+        * Returns the field the availability of the element dependents on or `null` if the field has
+        * not been set yet.
         * 
         * @return      IFormField      field controlling element availability
         */
        public function getField();
        
+       /**
+        * Returns the id of the field the availability of the node dependents on;
+        * 
+        * @return      string
+        * @throws      \BadMethodCallException         if neither field not field id has been set
+        */
+       public function getFieldId();
+       
        /**
         * Returns the JavaScript code required to ensure this dependency in the template.
         * 
index 2d6e5ee50db95510fd9791034dea70fd2df1a757..8341605b03b216b5776912052608c60d8f017960 100644 (file)
@@ -484,13 +484,12 @@ class ACLOptionPackageInstallationPlugin extends AbstractOptionPackageInstallati
                                                ->objectProperty('categoryname')
                                                ->label('wcf.acp.pip.aclOption.options.categoryName')
                                                ->description('wcf.acp.pip.aclOption.options.categoryName.description')
-                                               ->options(['' => 'wcf.global.noSelection'] + $categories[$objectTypeID]);
-                                       
-                                       $categoryNameField->addDependency(
-                                               ValueFormFieldDependency::create('objectType')
-                                                       ->field($objectTypeFormField)
-                                                       ->values([$objectType])
-                                       );
+                                               ->options(['' => 'wcf.global.noSelection'] + $categories[$objectTypeID])
+                                               ->addDependency(
+                                                       ValueFormFieldDependency::create('objectType')
+                                                               ->field($objectTypeFormField)
+                                                               ->values([$objectType])
+                                               );
                                        
                                        $dataContainer->appendChild($categoryNameField);
                                }
index 8ddb74c67b8f01fbf10a66663910e9083ace2131..6b4b1c352fb3cac444858e3047bc34a615d2b097 100644 (file)
@@ -69,15 +69,17 @@ class ACPMenuPackageInstallationPlugin extends AbstractMenuPackageInstallationPl
                        return $value === 0 || $value == 3;
                }));
                
-               $dataContainer->appendChild(IconFormField::create('icon')
+               $dataContainer->appendChild(
+                       IconFormField::create('icon')
                        ->label('wcf.acp.pip.acpMenu.icon')
-                       ->description('wcf.acp.pip.acpMenu.icon.description')
-                       ->required()
-                       ->addDependency(
-                               ValueFormFieldDependency::create('parentMenuItem')
-                                       ->field($parentMenuItemFormField)
-                                       ->values($iconParentMenuItems)
-                       ));
+                               ->description('wcf.acp.pip.acpMenu.icon.description')
+                               ->required()
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('parentMenuItem')
+                                               ->field($parentMenuItemFormField)
+                                               ->values($iconParentMenuItems)
+                               )
+               );
                
                // add additional data to default fields
                
index bb0ba01c1457d7f25be57b37270382a5ea68aac8..089684f1577e094926fe4b1e74e86a1bdbd0a3a2 100644 (file)
@@ -426,7 +426,11 @@ class BBCodePackageInstallationPlugin extends AbstractXMLPackageInstallationPlug
                                ->label('wcf.acp.pip.bbcode.buttonLabel')
                                ->description('wcf.acp.pip.bbcode.buttonLabel.description')
                                ->required()
-                               ->maximumLength(255),
+                               ->maximumLength(255)
+                               ->addDependency(
+                                       NonEmptyFormFieldDependency::create('showButton')
+                                               ->fieldId('showButton')
+                               ),
                        
                        RadioButtonFormField::create('iconType')
                                ->label('wcf.acp.pip.bbcode.iconType')
@@ -435,7 +439,11 @@ class BBCodePackageInstallationPlugin extends AbstractXMLPackageInstallationPlug
                                        'fontAwesome' => 'wcf.acp.pip.bbcode.iconType.fontAwesome',
                                ])
                                ->required()
-                               ->value('fontAwesome'),
+                               ->value('fontAwesome')
+                               ->addDependency(
+                                       NonEmptyFormFieldDependency::create('showButton')
+                                               ->fieldId('showButton')
+                               ),
                        
                        TextFormField::create('iconPath')
                                ->objectProperty('wysiwygicon')
@@ -452,12 +460,22 @@ class BBCodePackageInstallationPlugin extends AbstractXMLPackageInstallationPlug
                                                        )
                                                );
                                        }
-                               })),
+                               }))
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('iconType')
+                                               ->fieldId('iconType')
+                                               ->values(['filePath'])
+                               ),
                        
                        IconFormField::create('fontAwesomeIcon')
                                ->objectProperty('wysiwygicon')
                                ->label('wcf.acp.pip.bbcode.wysiwygIcon')
                                ->required()
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('iconType')
+                                               ->fieldId('iconType')
+                                               ->values(['fontAwesome'])
+                               )
                ]);
                
                $form->appendChild(
@@ -471,32 +489,6 @@ class BBCodePackageInstallationPlugin extends AbstractXMLPackageInstallationPlug
                
                // discard the `iconType` value as it is only used to distinguish the two icon input fields
                $form->getDataHandler()->add(new VoidFormFieldDataProcessor('iconType'));
-               
-               // add dependencies
-               /** @var BooleanFormField $showButton */
-               $showButton = $dataContainer->getNodeById('showButton');
-               
-               /** @var RadioButtonFormField $iconType */
-               $iconType = $dataContainer->getNodeById('iconType');
-               
-               $dataContainer->getNodeById('buttonLabel')->addDependency(
-                       NonEmptyFormFieldDependency::create('showButton')
-                               ->field($showButton)
-               );
-               $iconType->addDependency(
-                       NonEmptyFormFieldDependency::create('showButton')
-                               ->field($showButton)
-               );
-               $dataContainer->getNodeById('iconPath')->addDependency(
-                       ValueFormFieldDependency::create('iconType')
-                               ->field($iconType)
-                               ->values(['filePath'])
-               );
-               $dataContainer->getNodeById('fontAwesomeIcon')->addDependency(
-                       ValueFormFieldDependency::create('iconType')
-                               ->field($iconType)
-                               ->values(['fontAwesome'])
-               );
        }
        
        /**
index 2e7cc26249035e1f2431e558e570ce96e989d218..d0738ff9aff6209d2c9a743aa884a65bf6755ca7 100644 (file)
@@ -525,7 +525,12 @@ class BoxPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                                        asort($options);
                                        
                                        return $options;
-                               }),
+                               })
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('boxType')
+                                               ->fieldId('boxType')
+                                               ->values(['system'])
+                               ),
                        
                        SingleSelectionFormField::create('position')
                                ->label('wcf.acp.pip.box.position')
@@ -579,6 +584,12 @@ class BoxPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                                ->i18n()
                                ->i18nRequired()
                                ->languageItemPattern('__NONE__')
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('boxType')
+                                               ->fieldId('boxType')
+                                               ->values(['system'])
+                                               ->negate()
+                               )
                ]);
                
                // add box controller-specific form fields 
@@ -590,24 +601,6 @@ class BoxPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                                $boxController->addPipGuiFormFields($form, $objectType->objectType);
                        }
                }
-               
-               // add dependencies
-               
-               /** @var SingleSelectionFormField $boxType */
-               $boxType = $dataContainer->getNodeById('boxType');
-               
-               $dataContainer->getNodeById('objectType')->addDependency(
-                       ValueFormFieldDependency::create('boxType')
-                               ->field($boxType)
-                               ->values(['system'])
-               );
-               
-               $contentContainer->getNodeById('contentContent')->addDependency(
-                       ValueFormFieldDependency::create('pageType')
-                               ->field($boxType)
-                               ->values(['system'])
-                               ->negate()
-               );
        }
        
        /**
index 328777cfd29df3e3a24befa70cfdbfa0638547d4..374a2deac79fb07a67cf2adc5c909662c4795971 100644 (file)
@@ -357,7 +357,12 @@ class LanguagePackageInstallationPlugin extends AbstractXMLPackageInstallationPl
                                        
                                        return $categories;
                                }, false, false)
-                               ->filterable(),
+                               ->filterable()
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('languageCategoryIDMode')
+                                               ->fieldId('languageCategoryIDMode')
+                                               ->values(['selection'])
+                               ),
                        
                        TextFormField::create('languageCategory')
                                ->label('wcf.acp.language.item.languageCategoryID')
@@ -376,7 +381,12 @@ class LanguagePackageInstallationPlugin extends AbstractXMLPackageInstallationPl
                                                        )
                                                );
                                        }
-                               })),
+                               }))
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('languageCategoryIDMode')
+                                               ->fieldId('languageCategoryIDMode')
+                                               ->values(['new'])
+                               ),
                        
                        TextFormField::create('languageItem')
                                ->label('wcf.acp.language.item.languageItem')
@@ -487,21 +497,6 @@ class LanguagePackageInstallationPlugin extends AbstractXMLPackageInstallationPl
                                        ->description($description)
                        );
                }
-               
-               // add dependencies
-               /** @var SingleSelectionFormField $languageCategoryIDMode */
-               $languageCategoryIDMode = $dataContainer->getNodeById('languageCategoryIDMode');
-               
-               $dataContainer->getNodeById('languageCategoryID')->addDependency(
-                       ValueFormFieldDependency::create('languageCategoryIDMode')
-                               ->field($languageCategoryIDMode)
-                               ->values(['selection'])
-               );
-               $dataContainer->getNodeById('languageCategory')->addDependency(
-                       ValueFormFieldDependency::create('languageCategoryIDMode')
-                               ->field($languageCategoryIDMode)
-                               ->values(['new'])
-               );
        }
        
        /**
index 19d7ad164617f0debf165742641c77db2dfadf95..167b35ba6480f35e1dd4ba4907c362d6421e3618 100644 (file)
@@ -359,13 +359,23 @@ class MenuItemPackageInstallationPlugin extends AbstractXMLPackageInstallationPl
                                        }
                                        
                                        return $nestedOptions;
-                               }, true),
+                               }, true)
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('linkType')
+                                               ->fieldId('linkType')
+                                               ->values(['internal'])
+                               ),
                        
                        TextFormField::create('externalURL')
                                ->label('wcf.acp.pip.menuItem.externalURL')
                                ->description('wcf.acp.pip.menuItem.externalURL.description')
                                ->required()
                                ->i18n()
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('linkType')
+                                               ->fieldId('linkType')
+                                               ->values(['external'])
+                               )
                ]);
                
                /** @var SingleSelectionFormField $menuField */
@@ -413,22 +423,6 @@ class MenuItemPackageInstallationPlugin extends AbstractXMLPackageInstallationPl
                                'linkType'
                        );
                }
-               
-               // dependencies
-               
-               /** @var RadioButtonFormField $linkType */
-               $linkType = $form->getNodeById('linkType');
-               $form->getNodeById('menuItemPage')->addDependency(
-                       ValueFormFieldDependency::create('linkType')
-                               ->field($linkType)
-                               ->values(['internal'])
-                       );
-               
-               $form->getNodeById('externalURL')->addDependency(
-                       ValueFormFieldDependency::create('linkType')
-                               ->field($linkType)
-                               ->values(['external'])
-               );
        }
        
        /**
index a5b095a1661d636dbc47b4b198390812e77c3dcc..9cd6cf34203128b8ee0ee6ab7fab06cc3532d551 100644 (file)
@@ -359,7 +359,13 @@ class MenuPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                        SingleSelectionFormField::create('boxPosition')
                                ->label('wcf.acp.pip.menu.boxPosition')
                                ->description('wcf.acp.pip.menu.boxPosition.description')
-                               ->options(array_combine(Box::$availablePositions, Box::$availablePositions)),
+                               ->options(array_combine(Box::$availablePositions, Box::$availablePositions))
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('identifier')
+                                               ->fieldId('identifier')
+                                               ->values(['com.woltlab.wcf.MainMenu'])
+                                               ->negate()
+                               ),
                        
                        BooleanFormField::create('boxShowHeader')
                                ->label('wcf.acp.pip.menu.boxShowHeader'),
@@ -400,15 +406,6 @@ class MenuPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                                        ->field($createBox)
                        );
                }
-               
-               /** @var TextFormField $identifier */
-               $identifier = $form->getNodeById('identifier');
-               $form->getNodeById('boxPosition')->addDependency(
-                       ValueFormFieldDependency::create('identifier')
-                               ->field($identifier)
-                               ->values(['com.woltlab.wcf.MainMenu'])
-                               ->negate()
-               );
        }
        
        /**
index a5c09d126a16f07954d754d2bf2efcf14039b57d..de3e9dcfaef8a872c5491a792ffc446a83f27d26 100644 (file)
@@ -298,19 +298,14 @@ class ObjectTypePackageInstallationPlugin extends AbstractXMLPackageInstallation
                                                        );
                                                }
                                        }
-                               })),
+                               }))
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('definitionID')
+                                               ->fieldId('definitionID')
+                                               ->values(array_keys($this->definitionInterfaces))
+                               ),
                ]);
                
-               /** @var SingleSelectionFormField $definitionID */
-               $definitionID = $form->getNodeById('definitionID');
-               
-               // add general field dependencies
-               $form->getNodeById('className')->addDependency(
-                       ValueFormFieldDependency::create('definitionID')
-                               ->field($definitionID)
-                               ->values(array_keys($this->definitionInterfaces))
-               );
-               
                // add object type-specific fields
                
                // com.woltlab.wcf.adLocation
index 695c9279bb66a6900c71e221985e0a9ff8e4fe87..03ad87e38ddf163acbad8e1f844b017a7afa68e1 100644 (file)
@@ -144,6 +144,9 @@ class OptionPackageInstallationPlugin extends AbstractOptionPackageInstallationP
                
                switch ($this->entryType) {
                        case 'options':
+                               /** @var SingleSelectionFormField $optionType */
+                               $optionType = $form->getNodeById('optionType');
+                               
                                /** @var TextFormField $optionNameField */
                                $optionNameField = $dataContainer->getNodeById('optionName');
                                $optionNameField->addValidator(new FormFieldValidator('uniqueness', function(TextFormField $formField) {
@@ -184,7 +187,12 @@ class OptionPackageInstallationPlugin extends AbstractOptionPackageInstallationP
                                        ->objectProperty('selectoptions')
                                        ->label('wcf.acp.pip.abstractOption.options.selectOptions')
                                        ->description('wcf.acp.pip.option.abstractOption.selectOptions.description')
-                                       ->rows(5);
+                                       ->rows(5)
+                                       ->addDependency(
+                                               ValueFormFieldDependency::create('optionType')
+                                                       ->field($optionType)
+                                                       ->values($this->selectOptionOptionTypes)
+                                       );
                                
                                $dataContainer->insertBefore($selectOptions, 'enableOptions');
                                
@@ -196,37 +204,23 @@ class OptionPackageInstallationPlugin extends AbstractOptionPackageInstallationP
                                        BooleanFormField::create('supportI18n')
                                                ->objectProperty('supporti18n')
                                                ->label('wcf.acp.pip.option.options.supportI18n')
-                                               ->description('wcf.acp.pip.option.options.supportI18n.description'),
+                                               ->description('wcf.acp.pip.option.options.supportI18n.description')
+                                               ->addDependency(
+                                                       ValueFormFieldDependency::create('optionType')
+                                                               ->field($optionType)
+                                                               ->values($this->i18nOptionTypes)
+                                               ),
                                        
                                        BooleanFormField::create('requireI18n')
                                                ->objectProperty('requirei18n')
                                                ->label('wcf.acp.pip.option.options.requireI18n')
-                                               ->description('wcf.acp.pip.option.options.requireI18n.description'),
+                                               ->description('wcf.acp.pip.option.options.requireI18n.description')
+                                               ->addDependency(
+                                                       NonEmptyFormFieldDependency::create('supportI18n')
+                                                               ->fieldId('supportI18n')
+                                               ),
                                ]);
                                
-                               /** @var SingleSelectionFormField $optionType */
-                               $optionType = $form->getNodeById('optionType');
-                               
-                               /** @var BooleanFormField $supportI18n */
-                               $supportI18n = $form->getNodeById('supportI18n');
-                               
-                               $selectOptions->addDependency(
-                                       ValueFormFieldDependency::create('optionType')
-                                               ->field($optionType)
-                                               ->values($this->selectOptionOptionTypes)
-                               );
-                               
-                               $supportI18n->addDependency(
-                                       ValueFormFieldDependency::create('optionType')
-                                               ->field($optionType)
-                                               ->values($this->i18nOptionTypes)
-                               );
-                               
-                               $form->getNodeById('requireI18n')->addDependency(
-                                       NonEmptyFormFieldDependency::create('supportI18n')
-                                               ->field($supportI18n)
-                               );
-                               
                                // ensure proper normalization of select options
                                $form->getDataHandler()->add(new CustomFormFieldDataProcessor('selectOptions', function(IFormDocument $document, array $parameters) {
                                        if (isset($parameters['data']['selectoptions'])) {
index 778d5d1cd9509370b4d18af45c70ac746904f989..f9137da65caebb1b106654b6c8db37d339bb2405 100644 (file)
@@ -215,7 +215,12 @@ class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstal
                                ->description('wcf.acp.pip.templateListener.templateName.description')
                                ->required()
                                ->options(array_combine(array_keys($templateEvents), array_keys($templateEvents)))
-                               ->filterable(),
+                               ->filterable()
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('environment')
+                                               ->fieldId('environment')
+                                               ->values(['user'])
+                               ),
                        
                        SingleSelectionFormField::create('acpTemplateName')
                                ->objectProperty('templatename')
@@ -224,6 +229,11 @@ class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstal
                                ->required()
                                ->options(array_combine(array_keys($acpTemplateEvents), array_keys($acpTemplateEvents)))
                                ->filterable()
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('environment')
+                                               ->fieldId('environment')
+                                               ->values(['admin'])
+                               )
                ]);
                
                /** @var SingleSelectionFormField $frontendTemplateName */
@@ -362,20 +372,6 @@ class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstal
                                ))
                ]);
                
-               /** @var SingleSelectionFormField $environment */
-               $environment = $form->getNodeById('environment');
-               
-               $form->getNodeById('frontendTemplateName')->addDependency(
-                       ValueFormFieldDependency::create('environment')
-                               ->field($environment)
-                               ->values(['user'])
-               );
-               $form->getNodeById('acpTemplateName')->addDependency(
-                       ValueFormFieldDependency::create('environment')
-                               ->field($environment)
-                               ->values(['admin'])
-               );
-               
                // ensure proper normalization of template code
                $form->getDataHandler()->add(new CustomFormFieldDataProcessor('templateCode', function(IFormDocument $document, array $parameters) {
                        $parameters['data']['templatecode'] = StringUtil::unifyNewlines(StringUtil::escapeCDATA($parameters['data']['templatecode']));
index 8ea785b607988b4080802480aba4e1726f376c46..641398619dbbb3985530ca7f02d8768b9a233789 100644 (file)
@@ -220,7 +220,12 @@ class UserOptionPackageInstallationPlugin extends AbstractOptionPackageInstallat
                                ->objectProperty('selectoptions')
                                ->label('wcf.acp.pip.abstractOption.options.selectOptions')
                                ->description('wcf.acp.pip.abstractOption.options.selectOptions.description')
-                               ->rows(5);
+                               ->rows(5)
+                               ->addDependency(
+                                       ValueFormFieldDependency::create('optionType')
+                                               ->field($optionType)
+                                               ->values($this->selectOptionOptionTypes)
+                               );
                        
                        $dataContainer->insertBefore($selectOptions, 'enableOptions');
                        
@@ -314,12 +319,6 @@ class UserOptionPackageInstallationPlugin extends AbstractOptionPackageInstallat
                                        ),
                        ]);
                        
-                       $selectOptions->addDependency(
-                               ValueFormFieldDependency::create('optionType')
-                                       ->field($optionType)
-                                       ->values($this->selectOptionOptionTypes)
-                       );
-                       
                        // ensure proper normalization of select options
                        $form->getDataHandler()->add(new CustomFormFieldDataProcessor('selectOptions', function(IFormDocument $document, array $parameters) {
                                if (isset($parameters['data']['selectoptions'])) {