From: Matthias Schmidt Date: Sat, 19 Dec 2020 12:17:05 +0000 (+0100) Subject: Add autocomplete support for email form field X-Git-Tag: 5.4.0_Alpha_1~521^2~6 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2c2b8e5dea4f0a6b11aeeb4298303d15193089ac;p=GitHub%2FWoltLab%2FWCF.git Add autocomplete support for email form field --- diff --git a/com.woltlab.wcf/templates/__emailFormField.tpl b/com.woltlab.wcf/templates/__emailFormField.tpl index f183868abb..2e6bb1b488 100644 --- a/com.woltlab.wcf/templates/__emailFormField.tpl +++ b/com.woltlab.wcf/templates/__emailFormField.tpl @@ -4,6 +4,7 @@ *}value="{if !$field->isI18n() || !$field->hasI18nValues()}{$field->getValue()}{/if}" {* *}maxlength="191"{* *}{if !$field->getFieldClasses()|empty} class="{implode from=$field->getFieldClasses() item='class' glue=' '}{$class}{/implode}"{/if}{* + *}{if $field->getAutoComplete() !== null} autocomplete="{$field->getAutoComplete()}"{/if}{* *}{if $field->isAutofocused()} autofocus{/if}{* *}{if $field->isRequired()} required{/if}{* *}{if $field->isImmutable()} disabled{/if}{* diff --git a/wcfsetup/install/files/acp/templates/__emailFormField.tpl b/wcfsetup/install/files/acp/templates/__emailFormField.tpl index f183868abb..2e6bb1b488 100644 --- a/wcfsetup/install/files/acp/templates/__emailFormField.tpl +++ b/wcfsetup/install/files/acp/templates/__emailFormField.tpl @@ -4,6 +4,7 @@ *}value="{if !$field->isI18n() || !$field->hasI18nValues()}{$field->getValue()}{/if}" {* *}maxlength="191"{* *}{if !$field->getFieldClasses()|empty} class="{implode from=$field->getFieldClasses() item='class' glue=' '}{$class}{/implode}"{/if}{* + *}{if $field->getAutoComplete() !== null} autocomplete="{$field->getAutoComplete()}"{/if}{* *}{if $field->isAutofocused()} autofocus{/if}{* *}{if $field->isRequired()} required{/if}{* *}{if $field->isImmutable()} disabled{/if}{* diff --git a/wcfsetup/install/files/lib/system/form/builder/field/EmailFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/EmailFormField.class.php index 1abb9644a2..8305975b10 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/EmailFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/EmailFormField.class.php @@ -16,7 +16,8 @@ use wcf\util\UserUtil; * @package WoltLabSuite\Core\System\Form\Builder\Field * @since 5.2 */ -class EmailFormField extends AbstractFormField implements IAutoFocusFormField, ICssClassFormField, II18nFormField, IImmutableFormField, IPlaceholderFormField { +class EmailFormField extends AbstractFormField implements IAutoCompleteFormField, IAutoFocusFormField, ICssClassFormField, II18nFormField, IImmutableFormField, IPlaceholderFormField { + use TAutoCompleteFormField; use TAutoFocusFormField; use TCssClassFormField; use TImmutableFormField; @@ -43,6 +44,16 @@ class EmailFormField extends AbstractFormField implements IAutoFocusFormField, I $this->addFieldClass('long'); } + /** + * @inheritDoc + * @since 5.4 + */ + protected function getValidAutoCompleteTokens(): array { + return array_merge(['email'], array_map(function(string $context): string { + return $context . ' email'; + }, ['home', 'work', 'mobile', 'fax', 'pager'])); + } + /** * @inheritDoc */