From 8fa972e82b647c33dddbbdfc693b4d90e0b40c4a Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 21 Dec 2020 19:18:26 +0100 Subject: [PATCH] Add input mode support for `TextFormField` --- com.woltlab.wcf/templates/__textFormField.tpl | 1 + .../files/acp/templates/__textFormField.tpl | 1 + .../form/builder/field/TextFormField.class.php | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/com.woltlab.wcf/templates/__textFormField.tpl b/com.woltlab.wcf/templates/__textFormField.tpl index 8e8206151c..a87d857afd 100644 --- a/com.woltlab.wcf/templates/__textFormField.tpl +++ b/com.woltlab.wcf/templates/__textFormField.tpl @@ -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}{* diff --git a/wcfsetup/install/files/acp/templates/__textFormField.tpl b/wcfsetup/install/files/acp/templates/__textFormField.tpl index 8e8206151c..a87d857afd 100644 --- a/wcfsetup/install/files/acp/templates/__textFormField.tpl +++ b/wcfsetup/install/files/acp/templates/__textFormField.tpl @@ -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}{* diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php index 79c0dd54e0..28439b9cd7 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php @@ -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 */ -- 2.20.1