function SessionExampleForm::submitForm
File
-
modules/session_example/src/Form/SessionExampleForm.php, line 149
Class
- SessionExampleForm
- Form to allow the user to store information in their session.
Namespace
Drupal\session_example\Form
Code
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->setSessionValue('session_example.name', $form_state->getValue('name'));
$this->setSessionValue('session_example.email', $form_state->getValue('email'));
$this->setSessionValue('session_example.quest', $form_state->getValue('quest'));
$this->setSessionValue('session_example.color', $form_state->getValue('color'));
$this->messenger()
->addMessage($this->t('The session has been saved successfully. @link', [
'@link' => Link::createFromRoute('Check here.', 'session_example.view')->toString(),
]));
$this->invalidateCacheTag();
}