public function CurrencyImportForm::buildForm in Price 8
Same name and namespace in other branches
- 3.x src/Form/CurrencyImportForm.php \Drupal\price\Form\CurrencyImportForm::buildForm()
- 2.0.x src/Form/CurrencyImportForm.php \Drupal\price\Form\CurrencyImportForm::buildForm()
- 2.x src/Form/CurrencyImportForm.php \Drupal\price\Form\CurrencyImportForm::buildForm()
- 3.0.x src/Form/CurrencyImportForm.php \Drupal\price\Form\CurrencyImportForm::buildForm()
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 49
Class
- CurrencyImportForm
- Provides a form for importing currencies from library definitions.
Namespace
Drupal\price\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$currencies = $this->importer
->getImportable();
if (empty($currencies)) {
$form['message'] = [
'#markup' => $this
->t('All currencies have already been imported.'),
];
}
else {
$form['currency_codes'] = [
'#type' => 'select',
'#title' => $this
->t('Available currencies'),
'#options' => $currencies,
'#multiple' => TRUE,
'#size' => 10,
];
$form['actions']['#type'] = 'actions';
$form['actions']['import'] = [
'#type' => 'submit',
'#button_type' => 'primary',
'#name' => 'import',
'#value' => $this
->t('Add'),
'#submit' => [
'::submitForm',
],
];
}
return $form;
}