From: Joshua Rüsweg Date: Sun, 3 Feb 2019 18:22:11 +0000 (+0100) Subject: Add data handler for upload form fields X-Git-Tag: 5.2.0_Alpha_1~296^2~9 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=170a166da5173383a3c17dd995be28aefe961324;p=GitHub%2FWoltLab%2FWCF.git Add data handler for upload form fields See #2825 --- 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 *