You are here

public function Wizard::submitForm in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/ajax_example/src/Form/Wizard.php \Drupal\ajax_example\Form\Wizard::submitForm()

Save away the current information.

Overrides FormInterface::submitForm

File

ajax_example/src/Form/Wizard.php, line 222

Class

Wizard
AJAX example wizard.

Namespace

Drupal\ajax_example\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $messenger = $this
    ->messenger();
  $messenger
    ->addMessage($this
    ->t('Your information has been submitted:'));
  $messenger
    ->addMessage($this
    ->t('Name: @name', [
    '@name' => $form_state
      ->getValue([
      'step1',
      'name',
    ]),
  ]));
  $messenger
    ->addMessage($this
    ->t('Address: @address', [
    '@address' => $form_state
      ->getValue([
      'step2',
      'address',
    ]),
  ]));
  $messenger
    ->addMessage($this
    ->t('City: @city', [
    '@city' => $form_state
      ->getValue([
      'step3',
      'city',
    ]),
  ]));
}