public function UserPasswordForm::buildForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/user/src/Form/UserPasswordForm.php \Drupal\user\Form\UserPasswordForm::buildForm()
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request object.
Overrides FormInterface::buildForm
File
- core/
modules/ user/ src/ Form/ UserPasswordForm.php, line 72 - Contains \Drupal\user\Form\UserPasswordForm.
Class
- UserPasswordForm
- Provides a user password reset form.
Namespace
Drupal\user\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['name'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Username or email address'),
'#size' => 60,
'#maxlength' => max(USERNAME_MAX_LENGTH, Email::EMAIL_MAX_LENGTH),
'#required' => TRUE,
'#attributes' => array(
'autocorrect' => 'off',
'autocapitalize' => 'off',
'spellcheck' => 'false',
'autofocus' => 'autofocus',
),
);
// Allow logged in users to request this also.
$user = $this
->currentUser();
if ($user
->isAuthenticated()) {
$form['name']['#type'] = 'value';
$form['name']['#value'] = $user
->getEmail();
$form['mail'] = array(
'#prefix' => '<p>',
'#markup' => $this
->t('Password reset instructions will be mailed to %email. You must log out to use the password reset link in the email.', array(
'%email' => $user
->getEmail(),
)),
'#suffix' => '</p>',
);
}
else {
$form['mail'] = array(
'#prefix' => '<p>',
'#markup' => $this
->t('Password reset instructions will be sent to your registered email address.'),
'#suffix' => '</p>',
);
$form['name']['#default_value'] = $this
->getRequest()->query
->get('name');
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this
->t('Submit'),
);
return $form;
}