You are here

public function DefaultValueTestForm::submitForm in Address 8

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

tests/modules/address_test/src/Form/DefaultValueTestForm.php, line 91

Class

DefaultValueTestForm
Used to test the address default value handling inside complex ajax forms.

Namespace

Drupal\address_test\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $payment_method = $values['payment_method'];
  $address = $values[$payment_method]['address'];
  $this
    ->messenger()
    ->addMessage($this
    ->t('The street is "@street" and the country code is @country_code.', [
    '@street' => $address['address_line1'],
    '@country_code' => $address['country_code'],
  ]));
}