public function MultistepForm::submitForm in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/form_api_example/src/Form/MultistepForm.php \Drupal\form_api_example\Form\MultistepForm::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
- form_api_example/
src/ Form/ MultistepForm.php, line 86
Class
- MultistepForm
- Provides a form with two steps.
Namespace
Drupal\form_api_example\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$page_values = $form_state
->get('page_values');
$this
->messenger()
->addMessage($this
->t('The form has been submitted. name="@first @last", year of birth=@year_of_birth', [
'@first' => $page_values['first_name'],
'@last' => $page_values['last_name'],
'@year_of_birth' => $page_values['birth_year'],
]));
$this
->messenger()
->addMessage($this
->t('And the favorite color is @color', [
'@color' => $form_state
->getValue('color'),
]));
}