public function StateDemo::submitForm in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/form_api_example/src/Form/StateDemo.php \Drupal\form_api_example\Form\StateDemo::submitForm()
Implements submitForm callback.
@inheritdoc
Overrides DemoBase::submitForm
File
- form_api_example/
src/ Form/ StateDemo.php, line 95
Class
- StateDemo
- Implements the state demo form controller.
Namespace
Drupal\form_api_example\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Find out what was submitted.
$values = $form_state
->getValues();
if ($values['needs_accommodation']) {
$this
->messenger()
->addMessage($this
->t('Dietary Restriction Requested: %diet', [
'%diet' => $values['diet'],
]));
}
}