public function UserPasswordForm::submitForm in Drupal 9
Same name and namespace in other branches
- 8 core/modules/user/src/Form/UserPasswordForm.php \Drupal\user\Form\UserPasswordForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- core/
modules/ user/ src/ Form/ UserPasswordForm.php, line 207
Class
- UserPasswordForm
- Provides a user password reset form.
Namespace
Drupal\user\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$account = $form_state
->getValue('account');
if ($account) {
// Mail one time login URL and instructions using current language.
$mail = _user_mail_notify('password_reset', $account);
if (!empty($mail)) {
$this
->logger('user')
->notice('Password reset instructions mailed to %name at %email.', [
'%name' => $account
->getAccountName(),
'%email' => $account
->getEmail(),
]);
}
}
else {
$this
->logger('user')
->notice('Password reset form was submitted with an unknown or inactive account: %name.', [
'%name' => $form_state
->getValue('name'),
]);
}
// Make sure the status text is displayed even if no email was sent. This
// message is deliberately the same as the success message for privacy.
$this
->messenger()
->addStatus($this
->t('If %identifier is a valid account, an email will be sent with instructions to reset your password.', [
'%identifier' => $form_state
->getValue('name'),
]));
$form_state
->setRedirect('<front>');
}