Add input mode support for `AbstractNumericFormField`
authorMatthias Schmidt <gravatronics@live.com>
Mon, 21 Dec 2020 18:17:20 +0000 (19:17 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 21 Dec 2020 18:17:20 +0000 (19:17 +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 40baa2a2d12929c6b2b92b82da6f7b89de862b48..f180b72d62add3666d96b91c853e14b2ae594ab6 100644 (file)
@@ -14,6 +14,7 @@
        *}{if $field->isImmutable()} disabled{/if}{*
        *}{if $field->getMinimum() !== null} min="{$field->getMinimum()}"{/if}{*
        *}{if $field->getMaximum() !== null} max="{$field->getMaximum()}"{/if}{*
+       *}{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}{*
 *}>
index 40baa2a2d12929c6b2b92b82da6f7b89de862b48..f180b72d62add3666d96b91c853e14b2ae594ab6 100644 (file)
@@ -14,6 +14,7 @@
        *}{if $field->isImmutable()} disabled{/if}{*
        *}{if $field->getMinimum() !== null} min="{$field->getMinimum()}"{/if}{*
        *}{if $field->getMaximum() !== null} max="{$field->getMaximum()}"{/if}{*
+       *}{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}{*
 *}>
index e366f0ae6408220d84d56b11fd9cb4d14b57a81b..6e09e40390e076ed55f53b781bc3c99f0db6ad37 100644 (file)
@@ -11,11 +11,12 @@ 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, IMaximumFormField, IMinimumFormField, INullableFormField, IPlaceholderFormField, ISuffixedFormField {
+abstract class AbstractNumericFormField extends AbstractFormField implements IAutoCompleteFormField, IAutoFocusFormField, ICssClassFormField, IImmutableFormField, IInputModeFormField, IMaximumFormField, IMinimumFormField, INullableFormField, IPlaceholderFormField, ISuffixedFormField {
        use TAutoCompleteFormField;
        use TAutoFocusFormField;
        use TCssClassFormField;
        use TImmutableFormField;
+       use TInputModeFormField;
        use TMaximumFormField;
        use TMinimumFormField;
        use TNullableFormField;
@@ -98,6 +99,17 @@ abstract class AbstractNumericFormField extends AbstractFormField implements IAu
                return $this->step;
        }
        
+       /**
+        * @inheritDoc
+        */
+       protected function getValidInputModes(): array {
+               if ($this->integerValues) {
+                       return ['numeric'];
+               }
+               
+               return ['decimal'];
+       }
+       
        /**
         * @inheritDoc
         */