Expose additional settings of WysiwygFormField in WysiwygFormContainer
authorMatthias Schmidt <gravatronics@live.com>
Sun, 30 Jun 2019 13:11:11 +0000 (15:11 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 30 Jun 2019 13:11:11 +0000 (15:11 +0200)
See #2852

wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php
wcfsetup/install/files/lib/system/form/builder/field/AbstractFormField.class.php

index c5afc06f248aa42e5fa5ba9e0e9f83ef2aa6344a..5a5a57e5c1ee0dcd6b2c9d32b3e017ee20e8893c 100644 (file)
@@ -7,6 +7,10 @@ use wcf\system\event\EventHandler;
 use wcf\system\form\builder\button\wysiwyg\WysiwygPreviewFormButton;
 use wcf\system\form\builder\container\FormContainer;
 use wcf\system\form\builder\container\TabFormContainer;
+use wcf\system\form\builder\field\IMaximumLengthFormField;
+use wcf\system\form\builder\field\IMinimumLengthFormField;
+use wcf\system\form\builder\field\TMaximumLengthFormField;
+use wcf\system\form\builder\field\TMinimumLengthFormField;
 use wcf\system\form\builder\field\wysiwyg\WysiwygAttachmentFormField;
 use wcf\system\form\builder\field\wysiwyg\WysiwygFormField;
 use wcf\system\form\builder\IFormNode;
@@ -26,7 +30,9 @@ use wcf\system\form\builder\TWysiwygFormNode;
  * @package    WoltLabSuite\Core\System\Form\Builder\Container\Wysiwyg
  * @since      5.2
  */
-class WysiwygFormContainer extends FormContainer {
+class WysiwygFormContainer extends FormContainer implements IMaximumLengthFormField, IMinimumLengthFormField {
+       use TMaximumLengthFormField;
+       use TMinimumLengthFormField;
        use TWysiwygFormNode;
        
        /**
@@ -78,6 +84,12 @@ class WysiwygFormContainer extends FormContainer {
         */
        protected $quoteData;
        
+       /**
+        * `true` if the wysiwyg field has to be filled out and `false` otherwise
+        * @var bool
+        */
+       protected $required = false;
+       
        /**
         * settings form container
         * @var FormContainer
@@ -295,6 +307,16 @@ class WysiwygFormContainer extends FormContainer {
                return parent::id($id);
        }
        
+       /**
+        * Returns `true` if the wsyiwyg field has to be filled out and returns `false` otherwise.
+        * By default, the wsyiwyg field does not have to be filled out.
+        * 
+        * @return      bool
+        */
+       public function isRequired() {
+               return $this->required;
+       }
+       
        /**
         * Sets the message object type used by the wysiwyg form field.
         * 
@@ -370,6 +392,9 @@ class WysiwygFormContainer extends FormContainer {
                
                $this->wysiwygField = WysiwygFormField::create($this->wysiwygId)
                        ->objectType($this->messageObjectType)
+                       ->minimumLength($this->getMinimumLength())
+                       ->maximumLength($this->getMaximumLength())
+                       ->required($this->isRequired())
                        ->supportAttachments($this->attachmentData !== null)
                        ->supportMentions($this->supportMentions)
                        ->supportQuotes($this->supportQuotes);
@@ -487,6 +512,18 @@ class WysiwygFormContainer extends FormContainer {
                return $this;
        }
        
+       /**
+        * Sets whether it is required to fill out the wysiwyg field and returns this container.
+        * 
+        * @param       bool            $required       determines if field has to be filled out
+        * @return      static                          this container
+        */
+       public function required($required = true) {
+               $this->required = $required;
+               
+               return $this;
+       }
+       
        /**
         * Sets if mentions are supported by the editor field and returns this form container.
         * 
index 738cb2960b9f1b552476d61b3dadf78fd3e70e7d..a1b10e21eb327364c2c7aca38e8850f21caa3602 100644 (file)
@@ -34,7 +34,7 @@ abstract class AbstractFormField implements IFormField {
        protected $objectProperty;
        
        /**
-        * `true` if this field has to be filled out and returns `false` otherwise
+        * `true` if this field has to be filled out and `false` otherwise
         * @var bool
         */
        protected $required = false;