Add field CSS class support for `TextFormField`
authorMatthias Schmidt <gravatronics@live.com>
Sun, 20 Dec 2020 09:45:30 +0000 (10:45 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 20 Dec 2020 09:45:30 +0000 (10:45 +0100)
com.woltlab.wcf/templates/__textFormField.tpl
wcfsetup/install/files/acp/templates/__textFormField.tpl
wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php

index 8d73e00153ae9a75fe0c81449d49e0acb371902f..a918a0175defd25e6fc59379e60539fc1a5bcc23 100644 (file)
@@ -1,8 +1,8 @@
 <input type="text" {*
        *}id="{@$field->getPrefixedId()}" {*
        *}name="{@$field->getPrefixedId()}" {*
-       *}value="{if !$field->isI18n() || !$field->hasI18nValues() || $availableLanguages|count === 1}{$field->getValue()}{/if}" {*
-       *}class="long"{*
+       *}value="{if !$field->isI18n() || !$field->hasI18nValues() || $availableLanguages|count === 1}{$field->getValue()}{/if}"{*
+       *}{if !$field->getFieldClasses()|empty} class="{implode from=$field->getFieldClasses() item='class' glue=' '}{$class}{/implode}"{/if}{*
        *}{if $field->isAutofocused()} autofocus{/if}{*
        *}{if $field->isRequired()} required{/if}{*
        *}{if $field->isImmutable()} disabled{/if}{*
index 8d73e00153ae9a75fe0c81449d49e0acb371902f..a918a0175defd25e6fc59379e60539fc1a5bcc23 100644 (file)
@@ -1,8 +1,8 @@
 <input type="text" {*
        *}id="{@$field->getPrefixedId()}" {*
        *}name="{@$field->getPrefixedId()}" {*
-       *}value="{if !$field->isI18n() || !$field->hasI18nValues() || $availableLanguages|count === 1}{$field->getValue()}{/if}" {*
-       *}class="long"{*
+       *}value="{if !$field->isI18n() || !$field->hasI18nValues() || $availableLanguages|count === 1}{$field->getValue()}{/if}"{*
+       *}{if !$field->getFieldClasses()|empty} class="{implode from=$field->getFieldClasses() item='class' glue=' '}{$class}{/implode}"{/if}{*
        *}{if $field->isAutofocused()} autofocus{/if}{*
        *}{if $field->isRequired()} required{/if}{*
        *}{if $field->isImmutable()} disabled{/if}{*
index ff2f58caaecd7d1f67efdbb94478abb52eb790c8..aabc0bd1d1cd720b0bd77dcc0bd8e9a472d6fcbb 100644 (file)
@@ -13,8 +13,9 @@ use wcf\system\language\LanguageFactory;
  * @package    WoltLabSuite\Core\System\Form\Builder\Field
  * @since      5.2
  */
-class TextFormField extends AbstractFormField implements IAutoFocusFormField, II18nFormField, IImmutableFormField, IMaximumLengthFormField, IMinimumLengthFormField, IPlaceholderFormField {
+class TextFormField extends AbstractFormField implements IAutoFocusFormField, ICssClassFormField, II18nFormField, IImmutableFormField, IMaximumLengthFormField, IMinimumLengthFormField, IPlaceholderFormField {
        use TAutoFocusFormField;
+       use TCssClassFormField;
        use TImmutableFormField;
        use TI18nFormField {
                validate as protected i18nValidate;
@@ -33,6 +34,13 @@ class TextFormField extends AbstractFormField implements IAutoFocusFormField, II
         */
        protected $templateName = '__textFormField';
        
+       /**
+        * Creates a new instance of `TextFormField`.
+        */
+       public function __construct() {
+               $this->addFieldClass('long');
+       }
+       
        /**
         * @inheritDoc
         */