diff --git a/core/modules/contact/src/Tests/ContactPersonalTest.php b/core/modules/contact/src/Tests/ContactPersonalTest.php index 51124c9..2b0bf80 100644 --- a/core/modules/contact/src/Tests/ContactPersonalTest.php +++ b/core/modules/contact/src/Tests/ContactPersonalTest.php @@ -249,10 +249,10 @@ protected function checkContactAccess($response, $contact_value = NULL) { } $name = $this->randomMachineName(); $edit = array( - 'name' => $name, - 'mail' => $this->randomMachineName() . '@example.com', - 'pass[pass1]' => $pass = $this->randomString(), - 'pass[pass2]' => $pass, + 'name[0][value]' => $name, + 'mail[0][value]' => $this->randomMachineName() . '@example.com', + 'pass[0][value][pass1]' => $pass = $this->randomString(), + 'pass[0][value][pass2]' => $pass, 'notify' => FALSE, ); if (isset($contact_value)) { diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index 85cff65..137d11d 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -93,7 +93,6 @@ public function form(array $form, FormStateInterface $form_state) { if (!$register) { $form['pass']['#group'] = 'account'; - // To skip the current password field, the user must have logged in via a // one-time link and have the token in the URL. $pass_reset = isset($_SESSION['pass_reset_' . $account->id()]) && (\Drupal::request()->query->get('pass-reset-token') == $_SESSION['pass_reset_' . $account->id()]); @@ -135,16 +134,16 @@ public function form(array $form, FormStateInterface $form_state) { } } elseif (!$config->get('verify_mail') || $admin) { - $form['pass'][0]['value']['#description'] = $this->t('Provide a password for the new account in both fields.'); - $form['pass'][0]['value']['#required'] = TRUE; + $form['pass']['widget'][0]['value']['#description'] = $this->t('Provide a password for the new account in both fields.'); + $form['pass']['widget'][0]['value']['#required'] = TRUE; } // When not building the user registration form, prevent web browsers from // autofilling/prefilling the email, username, and password fields. if ($this->getOperation() != 'register') { foreach (array('mail', 'name', 'pass') as $key) { - if (isset($form['account'][$key])) { - $form['account'][$key]['#attributes']['autocomplete'] = 'off'; + if (isset($form[$key]['widget'][0]['value'])) { + $form[$key]['widget'][0]['value']['#attributes']['autocomplete'] = 'off'; } } } diff --git a/core/modules/user/src/Plugin/Field/FieldWidget/EmailUserWidget.php b/core/modules/user/src/Plugin/Field/FieldWidget/EmailUserWidget.php index f6acbea..241b640 100644 --- a/core/modules/user/src/Plugin/Field/FieldWidget/EmailUserWidget.php +++ b/core/modules/user/src/Plugin/Field/FieldWidget/EmailUserWidget.php @@ -39,7 +39,6 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // This allows users without e-mail address to be edited and deleted. '#required' => !(!$account->getEmail() && $user->hasPermission('administer users')), '#default_value' => (!$account->isAnonymous() ? $account->getEmail() : ''), - '#attributes' => array('autocomplete' => 'off'), ); return $element; diff --git a/core/modules/user/src/Plugin/Field/FieldWidget/UserNameWidget.php b/core/modules/user/src/Plugin/Field/FieldWidget/UserNameWidget.php index 9c60c00..6beaea3 100644 --- a/core/modules/user/src/Plugin/Field/FieldWidget/UserNameWidget.php +++ b/core/modules/user/src/Plugin/Field/FieldWidget/UserNameWidget.php @@ -36,13 +36,11 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $element['value'] = $element + array( '#type' => 'textfield', - '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, '#size' => $this->getSetting('size'), '#maxlength' => $this->getFieldSetting('max_length'), '#attributes' => array( 'class' => array('username'), 'autocorrect' => 'off', - 'autocomplete' => 'off', 'autocapitalize' => 'off', 'spellcheck' => 'false', ), diff --git a/core/modules/user/src/Tests/UserAccountFormFieldsTest.php b/core/modules/user/src/Tests/UserAccountFormFieldsTest.php index df01adc..c496a82 100644 --- a/core/modules/user/src/Tests/UserAccountFormFieldsTest.php +++ b/core/modules/user/src/Tests/UserAccountFormFieldsTest.php @@ -43,7 +43,7 @@ function testInstallConfigureForm() { // Verify that web browsers may autocomplete the email value and // autofill/prefill the name and pass values. foreach (array('mail', 'name', 'pass') as $key) { - $this->assertFalse(isset($form['account'][$key]['#attributes']['autocomplete']), "'$key' field: 'autocomplete' attribute not found."); + $this->assertFalse(isset($form['account'][$key]['widget'][0]['value']['#attributes']['autocomplete']), "'$key' field: 'autocomplete' attribute not found."); } } @@ -63,12 +63,12 @@ function testUserRegistrationForm() { $form = $this->buildAccountForm('register'); // Verify name and pass field order. - $this->assertFieldOrder($form['account']); + $this->assertFieldOrder($form); // Verify that web browsers may autocomplete the email value and // autofill/prefill the name and pass values. foreach (array('mail', 'name', 'pass') as $key) { - $this->assertFalse(isset($form['account'][$key]['#attributes']['autocomplete']), "'$key' field: 'autocomplete' attribute not found."); + $this->assertFalse(isset($form[$key]['widget'][0]['value']['#attributes']['autocomplete']), "'$key' field: 'autocomplete' attribute not found."); } } @@ -82,11 +82,11 @@ function testUserEditForm() { $form = $this->buildAccountForm('default'); // Verify name and pass field order. - $this->assertFieldOrder($form['account']); + $this->assertFieldOrder($form); // Verify that autocomplete is off on all account fields. foreach (array('mail', 'name', 'pass') as $key) { - $this->assertIdentical($form['account'][$key]['#attributes']['autocomplete'], 'off', "'$key' field: 'autocomplete' attribute is 'off'."); + $this->assertIdentical($form[$key]['widget'][0]['value']['#attributes']['autocomplete'], 'off', "'$key' field: 'autocomplete' attribute is 'off'."); } } diff --git a/core/modules/user/src/Tests/UserEditTest.php b/core/modules/user/src/Tests/UserEditTest.php index c37dd69..2b8ac98 100644 --- a/core/modules/user/src/Tests/UserEditTest.php +++ b/core/modules/user/src/Tests/UserEditTest.php @@ -47,7 +47,7 @@ function testUserEdit() { $edit = array(); $edit['mail[0][value]'] = $this->randomMachineName() . '@new.example.com'; $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); - $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => t('Email address')))); + $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => t('E-mail address')))); $edit['current_pass'] = $user1->pass_raw; $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); @@ -99,7 +99,7 @@ function testUserWithoutEmailEdit() { // This user has no email address. $user1->mail = ''; $user1->save(); - $this->drupalPostForm("user/" . $user1->id() . "/edit", array('mail' => ''), t('Save')); + $this->drupalPostForm("user/" . $user1->id() . "/edit", array('mail[0][value]' => ''), t('Save')); $this->assertRaw(t("The changes have been saved.")); } } diff --git a/core/modules/user/src/Tests/UserTranslationUITest.php b/core/modules/user/src/Tests/UserTranslationUITest.php index 5a98be4..aff8d52 100644 --- a/core/modules/user/src/Tests/UserTranslationUITest.php +++ b/core/modules/user/src/Tests/UserTranslationUITest.php @@ -49,7 +49,7 @@ protected function getTranslatorPermissions() { */ protected function getNewEntityValues($langcode) { // User name is not translatable hence we use a fixed value. - return array('name' => $this->name) + parent::getNewEntityValues($langcode); + return array('name' => [0 => ['value' => $this->name]]) + parent::getNewEntityValues($langcode); } }