You are here

public function TextForm::submitForm in Examples for Developers 3.x

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

modules/theming_example/src/Form/TextForm.php, line 44

Class

TextForm
A simple form that displays a textfield and submit button.

Namespace

Drupal\theming_example\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this
    ->messenger()
    ->addMessage($this
    ->t('You chose %input', [
    '%input' => $form_state
      ->getValue('text'),
  ]));
}