Use AbstractFormBuilderForm for UserGroupPromoteOwnerForm
authorMatthias Schmidt <gravatronics@live.com>
Sun, 14 Apr 2019 15:08:41 +0000 (17:08 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 14 Apr 2019 15:08:41 +0000 (17:08 +0200)
See #2890

wcfsetup/install/files/lib/acp/form/UserGroupPromoteOwnerForm.class.php

index 365a3985edbd8b15792e63d2bff22d55eedd8782..9ae2344294e58b20238a6f22169a1330af950105 100644 (file)
@@ -3,11 +3,10 @@ namespace wcf\acp\form;
 use wcf\data\user\group\UserGroup;
 use wcf\data\user\group\UserGroupAction;
 use wcf\form\AbstractForm;
+use wcf\form\AbstractFormBuilderForm;
 use wcf\system\exception\IllegalLinkException;
 use wcf\system\form\builder\container\FormContainer;
 use wcf\system\form\builder\field\RadioButtonFormField;
-use wcf\system\form\builder\FormDocument;
-use wcf\system\form\builder\IFormDocument;
 use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
 use wcf\util\HeaderUtil;
@@ -21,17 +20,12 @@ use wcf\util\HeaderUtil;
  * @package     WoltLabSuite\Core\Acp\Form
  * @since       5.2
  */
-class UserGroupPromoteOwnerForm extends AbstractForm {
+class UserGroupPromoteOwnerForm extends AbstractFormBuilderForm {
        /**
         * @inheritDoc
         */
        public $activeMenuItem = 'wcf.acp.menu.link.group.list';
        
-       /**
-        * @var IFormDocument
-        */
-       public $form;
-       
        /**
         * @var UserGroup
         */
@@ -66,51 +60,37 @@ class UserGroupPromoteOwnerForm extends AbstractForm {
                uasort($this->groups, function(UserGroup $a, UserGroup $b) {
                        return $a->getName() <=> $b->getName();
                });
-               
-               $this->form = FormDocument::create('promoteGroup')
-                       ->appendChild(
-                               FormContainer::create('groupSection')
-                                       ->appendChild(
-                                               RadioButtonFormField::create('groupID')
-                                                       ->label('wcf.acp.group.promoteOwner.group')
-                                                       ->required()
-                                                       ->options($this->groups)
-                                       )
-                       );
-               $this->form->action(LinkHandler::getInstance()->getLink('UserGroupPromoteOwner'));
-               $this->form->build();
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       public function readFormParameters() {
-               parent::readFormParameters();
-               
-               $this->form->readValues();
        }
        
        /**
         * @inheritDoc
         */
-       public function validate() {
-               parent::validate();
+       protected function createForm() {
+               parent::createForm();
                
-               $this->form->validate();
+               $this->form->appendChild(
+                       FormContainer::create('groupSection')
+                               ->appendChild(
+                                       RadioButtonFormField::create('groupID')
+                                               ->label('wcf.acp.group.promoteOwner.group')
+                                               ->required()
+                                               ->options($this->groups)
+                               )
+               );
        }
        
        /**
         * @inheritDoc
         */
        public function save() {
-               parent::save();
+               AbstractForm::save();
                
                $groupID = $this->form->getData()['data']['groupID'];
                
                $this->objectAction = new UserGroupAction([$this->groups[$groupID]], 'promoteOwner');
                $this->objectAction->executeAction();
                
-               $this->saved();
+               AbstractForm::saved();
                
                HeaderUtil::redirect(LinkHandler::getInstance()->getLink());
                exit;
@@ -123,7 +103,6 @@ class UserGroupPromoteOwnerForm extends AbstractForm {
                parent::assignVariables();
                
                WCF::getTPL()->assign([
-                       'form' => $this->form,
                        // Hide the notice on this page only.
                        '__wscMissingOwnerGroup' => false,
                ]);