public function SwitchUserForm::submitForm in Devel 8
Same name and namespace in other branches
- 8.3 src/Form/SwitchUserForm.php \Drupal\devel\Form\SwitchUserForm::submitForm()
- 8.2 src/Form/SwitchUserForm.php \Drupal\devel\Form\SwitchUserForm::submitForm()
- 4.x src/Form/SwitchUserForm.php \Drupal\devel\Form\SwitchUserForm::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
- src/
Form/ SwitchUserForm.php, line 98
Class
- SwitchUserForm
- Defines a form that allows privileged users to generate entities.
Namespace
Drupal\devel\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// 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);
}