summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-10-13 17:11:23 +0100
committerAlex Pott2016-10-13 17:11:23 +0100
commitf9e4a5c9ec24b3454b703cdea604b4fca5c9e19c (patch)
tree58a3e55fa9a4be2c97ea28b358ab016fa8d7a392
parentede2b8a29c47a230797b8c6fedf200d7da4cace2 (diff)
Issue #2453491 by olafkarsten, devpreview, mgifford, webflo: Account form username
-rw-r--r--core/modules/user/src/AccountForm.php2
-rw-r--r--core/modules/user/src/Tests/UserEditTest.php7
2 files changed, 8 insertions, 1 deletions
diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php
index dbdb08b..64c829a 100644
--- a/core/modules/user/src/AccountForm.php
+++ b/core/modules/user/src/AccountForm.php
@@ -106,7 +106,7 @@ abstract class AccountForm extends ContentEntityForm {
'autocapitalize' => 'off',
'spellcheck' => 'false',
),
- '#default_value' => (!$register ? $account->getUsername() : ''),
+ '#default_value' => (!$register ? $account->getAccountName() : ''),
'#access' => ($register || ($user->id() == $account->id() && $user->hasPermission('change own username')) || $admin),
);
diff --git a/core/modules/user/src/Tests/UserEditTest.php b/core/modules/user/src/Tests/UserEditTest.php
index 225b194..5b34d2e 100644
--- a/core/modules/user/src/Tests/UserEditTest.php
+++ b/core/modules/user/src/Tests/UserEditTest.php
@@ -25,6 +25,13 @@ class UserEditTest extends WebTestBase {
$this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
$this->assertRaw(t('The username %name is already taken.', array('%name' => $edit['name'])));
+ // Check that the default value in user name field
+ // is the raw value and not a formatted one.
+ \Drupal::state()->set('user_hooks_test_user_format_name_alter', TRUE);
+ \Drupal::service('module_installer')->install(['user_hooks_test']);
+ $this->drupalGet('user/' . $user1->id() . '/edit');
+ $this->assertFieldByName('name', $user1->getAccountName());
+
// Check that filling out a single password field does not validate.
$edit = array();
$edit['pass[pass1]'] = '';