I'm trying to do a redirect after hitting the submit button in a Drupal 8 reset password form.
I use the theme_form_alter
hook and a function as a new submit actions. The problem is, that the redirect works but no email is send.
If I uncomment the line for the new submit hook the mail is send but of course there is no redirect.
function theme_form_alter(&$form, &$form_state, $form_id) {
if($form['#form_id'] == 'user_pass') {
$form['actions']['submit']['#submit'][] = 'user_pass_redirect';
}
}
function user_pass_redirect(&$form, $form_state) {
$url = \Drupal\Core\Url::fromRoute('entity.node.canonical', [
'node' => '87',
]);
$form_state->setRedirectUrl($url);
}
I'm doing exactly the same thing for the contact_message_personal_form
form and it works.
So, I have no idea why that happens for the contact_message_personal_form
and the user_pass
has isn't working.
Thanks for your help