From 9ea83d23a64a4189684e6b3714a57fc66a06b17f Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Wed, 31 Jul 2024 07:57:28 +0200 Subject: [PATCH] Adds a FieldDataProcessor to insert into the fileIDs to the `$parameters` array --- .../field/FileProcessorFormField.class.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php index 3038e92020..500353548f 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php @@ -7,7 +7,9 @@ use wcf\data\file\FileList; use wcf\data\file\thumbnail\FileThumbnailList; use wcf\system\file\processor\FileProcessor; use wcf\system\file\processor\IFileProcessor; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; use wcf\system\form\builder\field\validation\FormFieldValidationError; +use wcf\system\form\builder\IFormDocument; use wcf\system\form\builder\TObjectTypeFormNode; use wcf\system\style\IFontAwesomeIcon; use wcf\util\ArrayUtil; @@ -79,6 +81,29 @@ final class FileProcessorFormField extends AbstractFormField ]; } + #[\Override] + public function populate() + { + parent::populate(); + + if ($this->isSingleFileUpload()) { + return $this; + } + + $this->getDocument()->getDataHandler()->addProcessor( + new CustomFormDataProcessor( + 'fileProcessor', + function (IFormDocument $document, array $parameters) { + $parameters[$this->getObjectProperty()] = $this->getValue(); + + return $parameters; + } + ) + ); + + return $this; + } + public function getFileProcessor(): IFileProcessor { return $this->getObjectType()->getProcessor(); -- 2.20.1