From 861c94306f583a9fbb6f1926105c329bbdb5fe19 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 24 Feb 2019 14:29:07 +0100 Subject: [PATCH] Add default id and default label to username form field See #2509 --- .../builder/field/user/UsernameFormField.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/user/UsernameFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/user/UsernameFormField.class.php index 73292bb43f..b3838e25dc 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/user/UsernameFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/user/UsernameFormField.class.php @@ -6,6 +6,7 @@ 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\TDefaultIdFormField; use wcf\system\form\builder\field\TImmutableFormField; use wcf\system\form\builder\field\TMaximumLengthFormField; use wcf\system\form\builder\field\TMinimumLengthFormField; @@ -17,6 +18,8 @@ use wcf\util\UserUtil; /** * Implementation of a form field to enter one non-existing username. * + * The default id of fields of this class is `username` and the default label is `wcf.user.username`. + * * Usernames have a minimum length of 3 characters and a maximum length of 100 characters by default. * * @author Matthias Schmidt @@ -26,6 +29,7 @@ use wcf\util\UserUtil; * @since 5.2 */ class UsernameFormField extends AbstractFormField implements IImmutableFormField, IMaximumLengthFormField, IMinimumLengthFormField, INullableFormField, IPlaceholderFormField { + use TDefaultIdFormField; use TImmutableFormField; use TMaximumLengthFormField; use TMinimumLengthFormField; @@ -41,6 +45,7 @@ class UsernameFormField extends AbstractFormField implements IImmutableFormField * Creates a new instance of `UsernameFormField`. */ public function __construct() { + $this->label('wcf.user.username'); $this->maximumLength(100); $this->minimumLength(3); } @@ -102,4 +107,11 @@ class UsernameFormField extends AbstractFormField implements IImmutableFormField parent::validate(); } + + /** + * @inheritDoc + */ + protected static function getDefaultId() { + return 'username'; + } } -- 2.20.1