From 9e819582e8a79761f750a5e76e61662f06d3d706 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Thu, 11 Jul 2019 14:46:24 +0200 Subject: [PATCH] Support setting up form field depdencies with field id only 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. --- .../system/form/builder/TFormNode.class.php | 18 +++++++ .../AbstractFormFieldDependency.class.php | 37 ++++++++++++-- .../dependency/IFormFieldDependency.class.php | 24 ++++++++- ...LOptionPackageInstallationPlugin.class.php | 13 +++-- ...ACPMenuPackageInstallationPlugin.class.php | 18 ++++--- .../BBCodePackageInstallationPlugin.class.php | 50 ++++++++----------- .../BoxPackageInstallationPlugin.class.php | 31 +++++------- ...anguagePackageInstallationPlugin.class.php | 29 +++++------ ...enuItemPackageInstallationPlugin.class.php | 28 ++++------- .../MenuPackageInstallationPlugin.class.php | 17 +++---- ...ectTypePackageInstallationPlugin.class.php | 17 +++---- .../OptionPackageInstallationPlugin.class.php | 46 ++++++++--------- ...istenerPackageInstallationPlugin.class.php | 26 ++++------ ...rOptionPackageInstallationPlugin.class.php | 13 +++-- 14 files changed, 197 insertions(+), 170 deletions(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php b/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php index 0a4872a805..9f9975d048 100644 --- a/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php @@ -1,6 +1,7 @@ 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; } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/dependency/AbstractFormFieldDependency.class.php b/wcfsetup/install/files/lib/system/form/builder/field/dependency/AbstractFormFieldDependency.class.php index d563b939ec..f806071b9a 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/dependency/AbstractFormFieldDependency.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/dependency/AbstractFormFieldDependency.class.php @@ -1,5 +1,6 @@ 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; } /** diff --git a/wcfsetup/install/files/lib/system/form/builder/field/dependency/IFormFieldDependency.class.php b/wcfsetup/install/files/lib/system/form/builder/field/dependency/IFormFieldDependency.class.php index 48abcdc7c5..d731bd4240 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/dependency/IFormFieldDependency.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/dependency/IFormFieldDependency.class.php @@ -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. * diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php index 2d6e5ee50d..8341605b03 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php @@ -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); } diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php index 8ddb74c67b..6b4b1c352f 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php @@ -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 diff --git a/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php index bb0ba01c14..089684f157 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php @@ -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']) - ); } /** diff --git a/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php index 2e7cc26249..d0738ff9af 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php @@ -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() - ); } /** diff --git a/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php index 328777cfd2..374a2deac7 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php @@ -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']) - ); } /** diff --git a/wcfsetup/install/files/lib/system/package/plugin/MenuItemPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/MenuItemPackageInstallationPlugin.class.php index 19d7ad1646..167b35ba64 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/MenuItemPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/MenuItemPackageInstallationPlugin.class.php @@ -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']) - ); } /** diff --git a/wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php index a5b095a166..9cd6cf3420 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php @@ -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() - ); } /** diff --git a/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php index a5c09d126a..de3e9dcfae 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php @@ -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 diff --git a/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php index 695c9279bb..03ad87e38d 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php @@ -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'])) { diff --git a/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php index 778d5d1cd9..f9137da65c 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php @@ -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'])); diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php index 8ea785b607..641398619d 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php @@ -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'])) { -- 2.20.1