function StateDemo::submitForm

Same name in other branches
  1. 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

modules/form_api_example/src/Form/StateDemo.php, line 95

Class

StateDemo
Implements the state demo form controller.

Namespace

Drupal\form_api_example\Form

Code

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'],
        ]));
    }
}