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

index 88c20257df06b4ef007e114f09c4ced1186eb000..6877a52355518233c155bdd3a48b1922847a5f99 100644 (file)
@@ -6,8 +6,8 @@
        *}step="{@$field->getStep()}" {*
        *}id="{@$field->getPrefixedId()}" {*
        *}name="{@$field->getPrefixedId()}" {*
-       *}value="{$field->getValue()}" {*
-       *}class="short"{*
+       *}value="{$field->getValue()}"{*
+       *}{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 88c20257df06b4ef007e114f09c4ced1186eb000..6877a52355518233c155bdd3a48b1922847a5f99 100644 (file)
@@ -6,8 +6,8 @@
        *}step="{@$field->getStep()}" {*
        *}id="{@$field->getPrefixedId()}" {*
        *}name="{@$field->getPrefixedId()}" {*
-       *}value="{$field->getValue()}" {*
-       *}class="short"{*
+       *}value="{$field->getValue()}"{*
+       *}{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 85faf4972d5a23f2910bec8530a96570e517192a..112e18887c1ddb6d5279c733eaa5ecf1431b435d 100644 (file)
@@ -11,8 +11,9 @@ use wcf\system\form\builder\field\validation\FormFieldValidationError;
  * @package    WoltLabSuite\Core\System\Form\Builder\Field
  * @since      5.2
  */
-abstract class AbstractNumericFormField extends AbstractFormField implements IAutoFocusFormField, IImmutableFormField, IMaximumFormField, IMinimumFormField, INullableFormField, IPlaceholderFormField, ISuffixedFormField {
+abstract class AbstractNumericFormField extends AbstractFormField implements IAutoFocusFormField, ICssClassFormField, IImmutableFormField, IMaximumFormField, IMinimumFormField, INullableFormField, IPlaceholderFormField, ISuffixedFormField {
        use TAutoFocusFormField;
+       use TCssClassFormField;
        use TImmutableFormField;
        use TMaximumFormField;
        use TMinimumFormField;
@@ -42,6 +43,13 @@ abstract class AbstractNumericFormField extends AbstractFormField implements IAu
         */
        protected $templateName = '__numericFormField';
        
+       /**
+        * Creates a new instance of `AbstractNumericFormField`.
+        */
+       public function __construct() {
+               $this->addFieldClass('short');
+       }
+       
        /**
         * Returns the default value for the input element's step attribute.
         *