Adds a FieldDataProcessor to insert into the fileIDs to the `$parameters` array
authorCyperghost <olaf_schmitz_1@t-online.de>
Wed, 31 Jul 2024 05:57:28 +0000 (07:57 +0200)
committerCyperghost <olaf_schmitz_1@t-online.de>
Wed, 31 Jul 2024 05:57:28 +0000 (07:57 +0200)
wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php

index 3038e92020f9ed9065eb365030f086cbcab4eb03..500353548f0b9c81d1a216db9d0230671310493e 100644 (file)
@@ -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();