public UserPasswordForm::buildForm(array $form, FormStateInterface $form_state)
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request object.
Overrides FormInterface::buildForm
File
- core/modules/user/src/Form/UserPasswordForm.php, line 67
Class
- UserPasswordForm
- Provides a user password reset form.
Namespace
Drupal\user\Form
Code
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; }
Please login to continue.