From 8bdbb251465f454d5d46513be3fb675b050a5662 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Thu, 12 Jul 2018 19:14:21 +0200 Subject: [PATCH] Update custom form field data processors See #2509 --- .../lib/system/form/builder/field/AclFormField.class.php | 2 +- .../lib/system/form/builder/field/ItemListFormField.class.php | 4 ++-- .../system/form/builder/field/SimpleAclFormField.class.php | 4 ++-- .../lib/system/form/builder/field/TI18nFormField.class.php | 4 ++-- .../system/form/builder/field/TMultipleFormField.class.php | 4 ++-- .../lib/system/form/builder/field/TagFormField.class.php | 4 ++-- .../lib/system/form/builder/field/WysiwygFormField.class.php | 4 +++- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/AclFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/AclFormField.class.php index 756b4a2823..3509bb799f 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/AclFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/AclFormField.class.php @@ -132,7 +132,7 @@ class AclFormField extends AbstractFormField implements IObjectTypeFormField { parent::populate(); $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('acl', function(IFormDocument $document, array $parameters) { - $parameters[$this->getId() . '_aclObjectTypeID'] = $this->getObjectType()->objectTypeID; + $parameters[$this->getObjectProperty() . '_aclObjectTypeID'] = $this->getObjectType()->objectTypeID; return $parameters; })); diff --git a/wcfsetup/install/files/lib/system/form/builder/field/ItemListFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/ItemListFormField.class.php index 327c010e21..4801ea2c31 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/ItemListFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/ItemListFormField.class.php @@ -99,8 +99,8 @@ class ItemListFormField extends AbstractFormField { // an array should be passed as a parameter outside of the `data` array if ($this->getSaveValueType() === self::SAVE_VALUE_TYPE_ARRAY) { $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('itemList', function(IFormDocument $document, array $parameters) { - if (is_array($this->getValue())) { - $parameters[$this->getId()] = $this->getValue(); + if ($this->checkDependencies() && is_array($this->getValue())) { + $parameters[$this->getObjectProperty()] = $this->getValue(); } return $parameters; diff --git a/wcfsetup/install/files/lib/system/form/builder/field/SimpleAclFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/SimpleAclFormField.class.php index c3a2ae873a..b4f62df815 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/SimpleAclFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/SimpleAclFormField.class.php @@ -49,8 +49,8 @@ class SimpleAclFormField extends AbstractFormField { parent::populate(); $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('i18n', function(IFormDocument $document, array $parameters) { - if (is_array($this->getValue()) && !empty($this->getValue())) { - $parameters[$this->getId()] = $this->getValue(); + if ($this->checkDependencies() && is_array($this->getValue()) && !empty($this->getValue())) { + $parameters[$this->getObjectProperty()] = $this->getValue(); } return $parameters; diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php index 44f0d65880..ed88f6e715 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php @@ -269,8 +269,8 @@ trait TI18nFormField { /** @var IFormDocument $document */ $document = $this->getDocument(); $document->getDataHandler()->add(new CustomFormFieldDataProcessor('i18n', function(IFormDocument $document, array $parameters) { - if ($this->hasI18nValues()) { - $parameters[$this->getId() . '_i18n'] = $this->getValue(); + if ($this->checkDependencies() && $this->hasI18nValues()) { + $parameters[$this->getObjectProperty() . '_i18n'] = $this->getValue(); } return $parameters; diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TMultipleFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TMultipleFormField.class.php index ef22d5edd7..b7e3b765c7 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TMultipleFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TMultipleFormField.class.php @@ -156,8 +156,8 @@ trait TMultipleFormField { if ($this->allowsMultiple()) { $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('multiple', function(IFormDocument $document, array $parameters) { - if (!empty($this->getValue())) { - $parameters[$this->getId()] = $this->getValue(); + if ($this->checkDependencies() && !empty($this->getValue())) { + $parameters[$this->getObjectProperty()] = $this->getValue(); } return $parameters; diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TagFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TagFormField.class.php index 79efe8dd21..3e8fde09a3 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TagFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TagFormField.class.php @@ -87,8 +87,8 @@ class TagFormField extends AbstractFormField implements IObjectTypeFormField { parent::populate(); $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('acl', function(IFormDocument $document, array $parameters) { - if ($this->getValue() !== null && !empty($this->getValue())) { - $parameters[$this->getId()] = $this->getValue(); + if ($this->checkDependencies() && $this->getValue() !== null && !empty($this->getValue())) { + $parameters[$this->getObjectProperty()] = $this->getValue(); } return $parameters; diff --git a/wcfsetup/install/files/lib/system/form/builder/field/WysiwygFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/WysiwygFormField.class.php index d3c650591e..47af359a80 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/WysiwygFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/WysiwygFormField.class.php @@ -110,7 +110,9 @@ class WysiwygFormField extends AbstractFormField implements IMaximumLengthFormFi parent::populate(); $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('wysiwyg', function(IFormDocument $document, array $parameters) { - $parameters[$this->getId() . 'HtmlInputProcessor'] = $this->htmlInputProcessor; + if ($this->checkDependencies()) { + $parameters[$this->getObjectProperty() . 'HtmlInputProcessor'] = $this->htmlInputProcessor; + } return $parameters; })); -- 2.20.1