You are here

public function CustomerProfileTestForm::submitForm in Commerce Core 8.2

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/order/tests/modules/commerce_order_test/src/Form/CustomerProfileTestForm.php, line 111

Class

CustomerProfileTestForm
A form for testing the customer_profile inline form.

Namespace

Drupal\commerce_order_test\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  /** @var \Drupal\commerce\Plugin\Commerce\InlineForm\EntityInlineFormInterface $inline_form */
  $inline_form = $form['profile']['#inline_form'];

  /** @var \Drupal\profile\Entity\ProfileInterface $profile */
  $profile = $inline_form
    ->getEntity();

  /** @var \Drupal\address\AddressInterface $address */
  $address = $profile
    ->get('address')
    ->first();
  $this
    ->messenger()
    ->addMessage(t('The street is "@street" and the country code is @country_code. Address book: @address_book.', [
    '@street' => $address
      ->getAddressLine1(),
    '@country_code' => $address
      ->getCountryCode(),
    '@address_book' => $profile
      ->getData('copy_to_address_book') ? 'Yes' : 'No',
  ]));
}