function AjaxAddMore::submitForm

Same name in other branches
  1. 8.x-1.x form_api_example/src/Form/AjaxAddMore.php \Drupal\form_api_example\Form\AjaxAddMore::submitForm()
  2. 4.0.x modules/form_api_example/src/Form/AjaxAddMore.php \Drupal\form_api_example\Form\AjaxAddMore::submitForm()

Final submit handler.

Reports what values were finally set.

Overrides DemoBase::submitForm

File

modules/form_api_example/src/Form/AjaxAddMore.php, line 138

Class

AjaxAddMore
Implements the ajax demo form controller.

Namespace

Drupal\form_api_example\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $values = $form_state->getValue([
        'names_fieldset',
        'name',
    ]);
    $output = $this->t('These people are coming to the picnic: @names', [
        '@names' => implode(', ', $values),
    ]);
    $this->messenger()
        ->addMessage($output);
}