Esempio n. 1
0
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $currencies = $this->currencyImporter->getImportable();
    if (empty($currencies)) {
      $form['message'] = [
        '#markup' => $this->t('All currencies have already been imported.'),
      ];
    }
    else {
      $form['currency_code'] = [
        '#type' => 'select',
        '#title' => $this->t('Currency'),
        '#required' => TRUE,
        '#options' => $currencies,
      ];
      $form['actions']['#type'] = 'actions';
      $form['actions']['import'] = [
        '#type' => 'submit',
        '#button_type' => 'primary',
        '#name' => 'import',
        '#value' => $this->t('Import'),
        '#submit' => ['::submitForm'],
      ];
    }

    return $form;
  }