Add input mode support for `TextFormField`
authorMatthias Schmidt <gravatronics@live.com>
Mon, 21 Dec 2020 18:18:26 +0000 (19:18 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 21 Dec 2020 18:18:26 +0000 (19:18 +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 8e8206151cc71267bcc2ba7422b4df3669b16baf..a87d857afd64f96f1088a57b3c2d30f3461cafce 100644 (file)
@@ -3,6 +3,7 @@
        *}name="{@$field->getPrefixedId()}" {*
        *}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->getInputMode() !== null} inputmode="{$field->getInputMode()}"{/if}{*
        *}{if $field->getAutoComplete() !== null} autocomplete="{$field->getAutoComplete()}"{/if}{*
        *}{if $field->isAutofocused()} autofocus{/if}{*
        *}{if $field->isRequired()} required{/if}{*
index 8e8206151cc71267bcc2ba7422b4df3669b16baf..a87d857afd64f96f1088a57b3c2d30f3461cafce 100644 (file)
@@ -3,6 +3,7 @@
        *}name="{@$field->getPrefixedId()}" {*
        *}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->getInputMode() !== null} inputmode="{$field->getInputMode()}"{/if}{*
        *}{if $field->getAutoComplete() !== null} autocomplete="{$field->getAutoComplete()}"{/if}{*
        *}{if $field->isAutofocused()} autofocus{/if}{*
        *}{if $field->isRequired()} required{/if}{*
index 79c0dd54e0948d421e52483bb23a1d73297e397c..28439b9cd7c3c527c3495a3b423359985c71584f 100644 (file)
@@ -13,11 +13,12 @@ use wcf\system\language\LanguageFactory;
  * @package    WoltLabSuite\Core\System\Form\Builder\Field
  * @since      5.2
  */
-class TextFormField extends AbstractFormField implements IAutoCompleteFormField, IAutoFocusFormField, ICssClassFormField, II18nFormField, IImmutableFormField, IMaximumLengthFormField, IMinimumLengthFormField, IPlaceholderFormField {
+class TextFormField extends AbstractFormField implements IAutoCompleteFormField, IAutoFocusFormField, ICssClassFormField, II18nFormField, IImmutableFormField, IInputModeFormField, IMaximumLengthFormField, IMinimumLengthFormField, IPlaceholderFormField {
        use TTextAutoCompleteFormField;
        use TAutoFocusFormField;
        use TCssClassFormField;
        use TImmutableFormField;
+       use TInputModeFormField;
        use TI18nFormField {
                validate as protected i18nValidate;
        }
@@ -42,6 +43,21 @@ class TextFormField extends AbstractFormField implements IAutoCompleteFormField,
                $this->addFieldClass('long');
        }
        
+       /**
+        * @inheritDoc
+        */
+       protected function getValidInputModes(): array {
+               return [
+                       'text',
+                       'tel',
+                       'url',
+                       'email',
+                       'numeric',
+                       'decimal',
+                       'search',
+               ];
+       }
+       
        /**
         * @inheritDoc
         */