function SwitchUserForm::submitForm
Same name in other branches
- 4.x src/Form/SwitchUserForm.php \Drupal\devel\Form\SwitchUserForm::submitForm()
Overrides FormInterface::submitForm
File
-
src/
Form/ SwitchUserForm.php, line 102
Class
- SwitchUserForm
- Define a form to allow the user to switch and become another user.
Namespace
Drupal\devel\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) : void {
// We cannot rely on automatic token creation, since the csrf seed changes
// after the redirect and the generated token is not more valid.
// @todo find another way to do this.
$url = Url::fromRoute('devel.switch', [
'name' => $form_state->getValue('username'),
]);
$url->setOption('query', [
'token' => $this->csrfToken
->get($url->getInternalPath()),
]);
$form_state->setRedirectUrl($url);
}