Simplify ReactionType(Add|Edit)Form
authorJoshua Rüsweg <josh@bastelstu.be>
Tue, 5 Feb 2019 11:33:21 +0000 (12:33 +0100)
committerJoshua Rüsweg <josh@bastelstu.be>
Tue, 5 Feb 2019 11:33:21 +0000 (12:33 +0100)
See #2825

wcfsetup/install/files/lib/acp/form/ReactionTypeAddForm.class.php
wcfsetup/install/files/lib/acp/form/ReactionTypeEditForm.class.php

index d5c2c2ff1c3b28462a9fd0c9bd16933a072e7c19..a95995369299fcce28791f0c3737949c3cf746d7 100644 (file)
@@ -46,11 +46,6 @@ class ReactionTypeAddForm extends AbstractFormBuilderForm {
         */
        public $neededModules = ['MODULE_LIKE'];
        
-       /**
-        * @var UploadFormField
-        */
-       protected $uploadFormField;
-       
        /**
         * @inheritDoc
         */
@@ -81,18 +76,16 @@ class ReactionTypeAddForm extends AbstractFormBuilderForm {
                                        ->label('wcf.acp.reactionType.isDisabled')
                        ]);
                
-               $this->uploadFormField = UploadFormField::create('iconFile')
-                       ->label('wcf.acp.reactionType.image')
-                       ->description('wcf.acp.reactionType.image.description')
-                       ->required()
-                       ->maximum(1)
-                       ->imageOnly(true)
-                       ->allowSvgImage(true);
-               
                $iconContainer = FormContainer::create('imageSection')
                        ->label('wcf.acp.reactionType.image')
                        ->appendChildren([
-                               $this->uploadFormField
+                               UploadFormField::create('iconFile')
+                                       ->label('wcf.acp.reactionType.image')
+                                       ->description('wcf.acp.reactionType.image.description')
+                                       ->required()
+                                       ->maximum(1)
+                                       ->imageOnly(true)
+                                       ->allowSvgImage(true)
                        ]);
                
                $this->form->appendChildren([
index fae735ed65d39d978b410e4ec59283409b19bbaa..af5f65af9572796667193badd4fe45e372e80b3c 100644 (file)
@@ -2,7 +2,6 @@
 namespace wcf\acp\form;
 use wcf\data\reaction\type\ReactionType;
 use wcf\system\exception\IllegalLinkException;
-use wcf\system\file\upload\UploadFile;
 
 /**
  * Represents the reaction type add form.
@@ -37,17 +36,4 @@ class ReactionTypeEditForm extends ReactionTypeAddForm {
                        }
                }
        }
-       
-       /**
-        * Sets the form data based on the current form object.
-        */
-       protected function setFormObjectData() {
-               parent::setFormObjectData(); 
-               
-               if (empty($_POST)) {
-                       $this->uploadFormField->value([
-                               new UploadFile(WCF_DIR . 'images/reaction/' . $this->formObject->iconFile, basename($this->formObject->iconFile), true, true, true)
-                       ]);
-               }
-       }
 }