Add autocomplete support for username form field
authorMatthias Schmidt <gravatronics@live.com>
Sat, 19 Dec 2020 12:16:33 +0000 (13:16 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 21 Dec 2020 17:53:09 +0000 (18:53 +0100)
com.woltlab.wcf/templates/__usernameFormField.tpl
wcfsetup/install/files/acp/templates/__usernameFormField.tpl
wcfsetup/install/files/lib/system/form/builder/field/user/UsernameFormField.class.php

index 4df1dfda1608d4c4c7db8ac7df422c86e1e23778..63dc44d04835f4e58f8af445451fe8cc6c8d000b 100644 (file)
@@ -3,6 +3,7 @@
        *}name="{@$field->getPrefixedId()}" {*
        *}value="{$field->getValue()}" {*
        *}class="long"{*
+       *}{if $field->getAutoComplete() !== null} autocomplete="{$field->getAutoComplete()}"{/if}{*
        *}{if $field->isAutofocused()} autofocus{/if}{*
        *}{if $field->isRequired()} required{/if}{*
        *}{if $field->isImmutable()} disabled{/if}{*
index 4df1dfda1608d4c4c7db8ac7df422c86e1e23778..63dc44d04835f4e58f8af445451fe8cc6c8d000b 100644 (file)
@@ -3,6 +3,7 @@
        *}name="{@$field->getPrefixedId()}" {*
        *}value="{$field->getValue()}" {*
        *}class="long"{*
+       *}{if $field->getAutoComplete() !== null} autocomplete="{$field->getAutoComplete()}"{/if}{*
        *}{if $field->isAutofocused()} autofocus{/if}{*
        *}{if $field->isRequired()} required{/if}{*
        *}{if $field->isImmutable()} disabled{/if}{*
index 90e73faa8b033258aacf727afa06f9e4b3eaa21b..b13a86d8d455920f00b5a70e282223436797e759 100644 (file)
@@ -1,12 +1,14 @@
 <?php
 namespace wcf\system\form\builder\field\user;
 use wcf\system\form\builder\field\AbstractFormField;
+use wcf\system\form\builder\field\IAutoCompleteFormField;
 use wcf\system\form\builder\field\IAutoFocusFormField;
 use wcf\system\form\builder\field\IImmutableFormField;
 use wcf\system\form\builder\field\IMaximumLengthFormField;
 use wcf\system\form\builder\field\IMinimumLengthFormField;
 use wcf\system\form\builder\field\INullableFormField;
 use wcf\system\form\builder\field\IPlaceholderFormField;
+use wcf\system\form\builder\field\TAutoCompleteFormField;
 use wcf\system\form\builder\field\TAutoFocusFormField;
 use wcf\system\form\builder\field\TDefaultIdFormField;
 use wcf\system\form\builder\field\TImmutableFormField;
@@ -30,7 +32,8 @@ use wcf\util\UserUtil;
  * @package    WoltLabSuite\Core\System\Form\Builder\Field\User
  * @since      5.2
  */
-class UsernameFormField extends AbstractFormField implements IAutoFocusFormField, IImmutableFormField, IMaximumLengthFormField, IMinimumLengthFormField, INullableFormField, IPlaceholderFormField {
+class UsernameFormField extends AbstractFormField implements IAutoCompleteFormField, IAutoFocusFormField, IImmutableFormField, IMaximumLengthFormField, IMinimumLengthFormField, INullableFormField, IPlaceholderFormField {
+       use TAutoCompleteFormField;
        use TAutoFocusFormField;
        use TDefaultIdFormField;
        use TImmutableFormField;
@@ -58,6 +61,14 @@ class UsernameFormField extends AbstractFormField implements IAutoFocusFormField
                $this->minimumLength(3);
        }
        
+       /**
+        * @inheritDoc
+        * @since       5.4
+        */
+       protected function getValidAutoCompleteTokens(): array {
+               return ['username'];
+       }
+       
        /**
         * @inheritDoc
         */