From 170a166da5173383a3c17dd995be28aefe961324 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Sun, 3 Feb 2019 19:22:11 +0100 Subject: [PATCH] Add data handler for upload form fields See #2825 --- .../builder/field/UploadFormField.class.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php index a0dd65bf74..3c0dff9dae 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php @@ -3,7 +3,9 @@ namespace wcf\system\form\builder\field; use wcf\system\file\upload\UploadField; use wcf\system\file\upload\UploadFile; use wcf\system\file\upload\UploadHandler; +use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; use wcf\system\form\builder\field\validation\FormFieldValidationError; +use wcf\system\form\builder\IFormDocument; /** * Implementation of a form field for to uploads. @@ -194,6 +196,22 @@ class UploadFormField extends AbstractFormField { return $this; } + /** + * @inheritDoc + */ + public function populate() { + parent::populate(); + + $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('upload', function(IFormDocument $document, array $parameters) { + $parameters[$this->getId()] = $this->getValue(); + $parameters[$this->getId() . '_removedFiles'] = $this->getRemovedFiles(true); + + return $parameters; + })); + + return $this; + } + /** * @inheritDoc * -- 2.20.1