You are here

public function CurrencyImportForm::submitForm in Price 8

Same name and namespace in other branches
  1. 3.x src/Form/CurrencyImportForm.php \Drupal\price\Form\CurrencyImportForm::submitForm()
  2. 2.0.x src/Form/CurrencyImportForm.php \Drupal\price\Form\CurrencyImportForm::submitForm()
  3. 2.x src/Form/CurrencyImportForm.php \Drupal\price\Form\CurrencyImportForm::submitForm()
  4. 3.0.x src/Form/CurrencyImportForm.php \Drupal\price\Form\CurrencyImportForm::submitForm()

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

src/Form/CurrencyImportForm.php, line 80

Class

CurrencyImportForm
Provides a form for importing currencies from library definitions.

Namespace

Drupal\price\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $currency_codes = $form_state
    ->getValue('currency_codes');
  foreach ($currency_codes as $currency_code) {
    $this->importer
      ->import($currency_code);
  }
  $this
    ->messenger()
    ->addMessage($this
    ->t('Imported the selected currencies.'));
  $form_state
    ->setRedirect('entity.price_currency.collection');
}