From bc280c65a3cb999c849d296b870cfbbba300407b Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Tue, 4 Nov 2025 12:49:17 +0100 Subject: [PATCH] Add missing support for the `staticDictionary` to the `PasswordFormField` --- .../templates/shared_passwordFormField.tpl | 5 +++ .../files/lib/form/NewPasswordForm.class.php | 1 + .../builder/field/PasswordFormField.class.php | 34 ++++++++++++++++--- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/com.woltlab.wcf/templates/shared_passwordFormField.tpl b/com.woltlab.wcf/templates/shared_passwordFormField.tpl index d4d606da762..c6f2f5d8c54 100644 --- a/com.woltlab.wcf/templates/shared_passwordFormField.tpl +++ b/com.woltlab.wcf/templates/shared_passwordFormField.tpl @@ -27,6 +27,11 @@ document.getElementById('{unsafe:$fieldId|encodeJS}'), {/foreach} ], + staticDictionary: [ + {foreach from=$field->getStaticDictionary() item=staticDictionary} + '{unsafe:$staticDictionary|encodeJS}', + {/foreach} + ], }); }); diff --git a/wcfsetup/install/files/lib/form/NewPasswordForm.class.php b/wcfsetup/install/files/lib/form/NewPasswordForm.class.php index 7500ab39aca..ecc4acb8874 100644 --- a/wcfsetup/install/files/lib/form/NewPasswordForm.class.php +++ b/wcfsetup/install/files/lib/form/NewPasswordForm.class.php @@ -107,6 +107,7 @@ protected function createForm() ->addFieldClass('long') ->autocomplete('new-password') ->fieldAttribute('passwordrules', UserRegistrationUtil::getPasswordRulesAttributeValue()) + ->addStaticDictionary([$this->user->username, $this->user->email]) ->addValidator(new FormFieldValidator( 'passwordValidator', $this->validatePassword(...) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/PasswordFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/PasswordFormField.class.php index 0668be0c110..df1ddd3d685 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/PasswordFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/PasswordFormField.class.php @@ -7,10 +7,10 @@ /** * Implementation of a form field for a password. * - * @author Matthias Schmidt - * @copyright 2001-2021 WoltLab GmbH - * @license GNU Lesser General Public License - * @since 5.4 + * @author Matthias Schmidt + * @copyright 2001-2025 WoltLab GmbH + * @license GNU Lesser General Public License + * @since 5.4 */ class PasswordFormField extends AbstractFormField implements IAttributeFormField, @@ -63,6 +63,12 @@ class PasswordFormField extends AbstractFormField implements */ protected array $relatedFieldsId = []; + /** + * @var string[] + * @since 6.2 + */ + protected array $staticDictionary = []; + /** * Creates a new instance of `PasswordFormField`. */ @@ -181,4 +187,24 @@ public function getRelatedFieldsIDs(): array return $result; } + + /** + * @param string[] $staticDictionary + * @since 6.2 + */ + public function addStaticDictionary(array $staticDictionary): static + { + $this->staticDictionary = \array_merge($this->staticDictionary, $staticDictionary); + + return $this; + } + + /** + * @return string[] + * @since 6.2 + */ + public function getStaticDictionary(): array + { + return $this->staticDictionary; + } }