Add field attribute support for `AbstractNumericFormField`
authorMatthias Schmidt <gravatronics@live.com>
Wed, 23 Dec 2020 14:19:32 +0000 (15:19 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 23 Dec 2020 14:24:19 +0000 (15:24 +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 f180b72d62add3666d96b91c853e14b2ae594ab6..8142a1e21b9833628189af2e5bba9fd70d176437 100644 (file)
@@ -17,6 +17,7 @@
        *}{if $field->getInputMode() !== null} inputmode="{$field->getInputMode()}"{/if}{*
        *}{if $field->getPlaceholder() !== null} placeholder="{$field->getPlaceholder()}"{/if}{*
        *}{if $field->getDocument()->isAjax()} data-dialog-submit-on-enter="true"{/if}{*
+       *}{foreach from=$field->getFieldAttributes() key='attributeName' item='attributeValue'} {$attributeName}="{$attributeValue}"{/foreach}{*
 *}>
 
 {if $field->getSuffix() !== null}
index f180b72d62add3666d96b91c853e14b2ae594ab6..8142a1e21b9833628189af2e5bba9fd70d176437 100644 (file)
@@ -17,6 +17,7 @@
        *}{if $field->getInputMode() !== null} inputmode="{$field->getInputMode()}"{/if}{*
        *}{if $field->getPlaceholder() !== null} placeholder="{$field->getPlaceholder()}"{/if}{*
        *}{if $field->getDocument()->isAjax()} data-dialog-submit-on-enter="true"{/if}{*
+       *}{foreach from=$field->getFieldAttributes() key='attributeName' item='attributeValue'} {$attributeName}="{$attributeValue}"{/foreach}{*
 *}>
 
 {if $field->getSuffix() !== null}
index 6e09e40390e076ed55f53b781bc3c99f0db6ad37..60d14000d06094b2198f6ddca7188f32ace6f9ff 100644 (file)
@@ -11,7 +11,10 @@ use wcf\system\form\builder\field\validation\FormFieldValidationError;
  * @package    WoltLabSuite\Core\System\Form\Builder\Field
  * @since      5.2
  */
-abstract class AbstractNumericFormField extends AbstractFormField implements IAutoCompleteFormField, IAutoFocusFormField, ICssClassFormField, IImmutableFormField, IInputModeFormField, IMaximumFormField, IMinimumFormField, INullableFormField, IPlaceholderFormField, ISuffixedFormField {
+abstract class AbstractNumericFormField extends AbstractFormField implements IAttributeFormField, IAutoCompleteFormField, IAutoFocusFormField, ICssClassFormField, IImmutableFormField, IInputModeFormField, IMaximumFormField, IMinimumFormField, INullableFormField, IPlaceholderFormField, ISuffixedFormField {
+       use TAttributeFormField {
+               getReservedFieldAttributes as private defaultGetReservedFieldAttributes;
+       }
        use TAutoCompleteFormField;
        use TAutoFocusFormField;
        use TCssClassFormField;
@@ -213,4 +216,17 @@ abstract class AbstractNumericFormField extends AbstractFormField implements IAu
                
                return parent::value($value);
        }
+       
+       /**
+        * @inheritDoc
+        * @since       5.4
+        */
+       protected static function getReservedFieldAttributes(): array {
+               return array_merge(
+                       static::defaultGetReservedFieldAttributes(),
+                       [
+                               'step',
+                       ]
+               );
+       }
 }