You are here

public function CurrencyImportForm::buildForm in Currency 8.3

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/CurrencyImportForm.php, line 67

Class

CurrencyImportForm
Provides the currency import form.

Namespace

Drupal\currency\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $currencies = $this->configImporter
    ->getImportableCurrencies();
  if (empty($currencies)) {
    $form['message'] = [
      '#markup' => $this
        ->t('All currencies have been imported already.'),
    ];
  }
  else {
    $form['currency_code'] = [
      '#options' => $this->formHelper
        ->getCurrencyOptions($currencies),
      '#required' => TRUE,
      '#title' => $this
        ->t('Currency'),
      '#type' => 'select',
    ];
    $form['actions'] = [
      '#type' => 'actions',
    ];
    $form['actions']['import'] = [
      '#dropbutton' => 'submit',
      '#name' => 'import',
      '#type' => 'submit',
      '#value' => $this
        ->t('Import'),
    ];
    $form['actions']['import_edit'] = [
      '#dropbutton' => 'submit',
      '#name' => 'import_edit',
      '#type' => 'submit',
      '#value' => $this
        ->t('Import and edit'),
    ];
  }
  return $form;
}