You are here

public function Autotextfields::submitForm in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/ajax_example/src/Form/Autotextfields.php \Drupal\ajax_example\Form\Autotextfields::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

ajax_example/src/Form/Autotextfields.php, line 103

Class

Autotextfields
Show textfields based on AJAX-enabled checkbox clicks.

Namespace

Drupal\ajax_example\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this
    ->messenger()
    ->addMessage($this
    ->t('Submit handler: First name: @first_name Last name: @last_name', [
    '@first_name' => $form_state
      ->getValue('first_name', 'n/a'),
    '@last_name' => $form_state
      ->getValue('last_name', 'n/a'),
  ]));
}