Skip to content

Commit eefebc3

Browse files
authored
Merge pull request #6508 from WoltLab/6.2-password-form-field-static-dictionary
Add missing support for the `staticDictionary` to the `PasswordFormField`
2 parents 8af745e + bc280c6 commit eefebc3

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

com.woltlab.wcf/templates/shared_passwordFormField.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
document.getElementById('{unsafe:$fieldId|encodeJS}'),
2828
{/foreach}
2929
],
30+
staticDictionary: [
31+
{foreach from=$field->getStaticDictionary() item=staticDictionary}
32+
'{unsafe:$staticDictionary|encodeJS}',
33+
{/foreach}
34+
],
3035
});
3136
});
3237
</script>

wcfsetup/install/files/lib/form/NewPasswordForm.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ protected function createForm()
107107
->addFieldClass('long')
108108
->autocomplete('new-password')
109109
->fieldAttribute('passwordrules', UserRegistrationUtil::getPasswordRulesAttributeValue())
110+
->addStaticDictionary([$this->user->username, $this->user->email])
110111
->addValidator(new FormFieldValidator(
111112
'passwordValidator',
112113
$this->validatePassword(...)

wcfsetup/install/files/lib/system/form/builder/field/PasswordFormField.class.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
/**
88
* Implementation of a form field for a password.
99
*
10-
* @author Matthias Schmidt
11-
* @copyright 2001-2021 WoltLab GmbH
12-
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13-
* @since 5.4
10+
* @author Matthias Schmidt
11+
* @copyright 2001-2025 WoltLab GmbH
12+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13+
* @since 5.4
1414
*/
1515
class PasswordFormField extends AbstractFormField implements
1616
IAttributeFormField,
@@ -63,6 +63,12 @@ class PasswordFormField extends AbstractFormField implements
6363
*/
6464
protected array $relatedFieldsId = [];
6565

66+
/**
67+
* @var string[]
68+
* @since 6.2
69+
*/
70+
protected array $staticDictionary = [];
71+
6672
/**
6773
* Creates a new instance of `PasswordFormField`.
6874
*/
@@ -181,4 +187,24 @@ public function getRelatedFieldsIDs(): array
181187

182188
return $result;
183189
}
190+
191+
/**
192+
* @param string[] $staticDictionary
193+
* @since 6.2
194+
*/
195+
public function addStaticDictionary(array $staticDictionary): static
196+
{
197+
$this->staticDictionary = \array_merge($this->staticDictionary, $staticDictionary);
198+
199+
return $this;
200+
}
201+
202+
/**
203+
* @return string[]
204+
* @since 6.2
205+
*/
206+
public function getStaticDictionary(): array
207+
{
208+
return $this->staticDictionary;
209+
}
184210
}

0 commit comments

Comments
 (0)