You are here

public function AjaxPriceTestForm::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/price/tests/modules/commerce_price_test/src/Form/AjaxPriceTestForm.php, line 52

Class

AjaxPriceTestForm
A form for testing AJAX on commerce_price elements.

Namespace

Drupal\commerce_price_test\Form

Code

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

  // Create a Price to ensure the values are valid.
  $values = $form_state
    ->getValues();
  $price = Price::fromArray($values['amount']);
  $this
    ->messenger()
    ->addMessage($this
    ->t('The number is "@number" and the currency code is "@currency_code".', [
    '@number' => $price
      ->getNumber(),
    '@currency_code' => $price
      ->getCurrencyCode(),
  ]));
}