Add autocomplete support for email form field
authorMatthias Schmidt <gravatronics@live.com>
Sat, 19 Dec 2020 12:17:05 +0000 (13:17 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 21 Dec 2020 17:54:48 +0000 (18:54 +0100)
com.woltlab.wcf/templates/__emailFormField.tpl
wcfsetup/install/files/acp/templates/__emailFormField.tpl
wcfsetup/install/files/lib/system/form/builder/field/EmailFormField.class.php

index f183868abb3696d22ca53338aaee2afe229abef9..2e6bb1b488a1c749071eac22233948df63f5a3cb 100644 (file)
@@ -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}{*
index f183868abb3696d22ca53338aaee2afe229abef9..2e6bb1b488a1c749071eac22233948df63f5a3cb 100644 (file)
@@ -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}{*
index 1abb9644a229413426564aa1f051d2fb46ca4a08..8305975b10940666fb6c52893d46e1ecb74ddf77 100644 (file)
@@ -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
         */