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

index 23fe7f1f7684fa292786546d43e75b4dae06862c..a0a4594f1b2b0254822f3df996111077b2d4217c 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->getPlaceholder() !== null} placeholder="{$field->getPlaceholder()}"{/if}{*
index 23fe7f1f7684fa292786546d43e75b4dae06862c..a0a4594f1b2b0254822f3df996111077b2d4217c 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->getPlaceholder() !== null} placeholder="{$field->getPlaceholder()}"{/if}{*
index 0dab0ed072cf64b289a11c6fa4a27e5ce55b713b..669b068b552f03b1cab41a16edc1060862e7bc37 100644 (file)
@@ -1,8 +1,10 @@
 <?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\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\TPlaceholderFormField;
@@ -22,7 +24,8 @@ use wcf\system\WCF;
  * @package     WoltLabSuite\Core\System\Form\Builder\Field\User
  * @since       5.4
  */
-class UserPasswordField extends AbstractFormField implements IAutoFocusFormField, IPlaceholderFormField {
+class UserPasswordField extends AbstractFormField implements IAutoCompleteFormField, IAutoFocusFormField, IPlaceholderFormField {
+       use TAutoCompleteFormField;
        use TAutoFocusFormField;
        use TDefaultIdFormField;
        use TPlaceholderFormField;
@@ -51,6 +54,14 @@ class UserPasswordField extends AbstractFormField implements IAutoFocusFormField
                return 'password';
        }
        
+       /**
+        * @inheritDoc
+        * @since       5.4
+        */
+       protected function getValidAutoCompleteTokens(): array {
+               return ['current-password'];
+       }
+       
        /**
         * @inheritDoc
         */