You are here

public function AmountFormattingForm::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 ConfigFormBase::buildForm

File

src/Form/AmountFormattingForm.php, line 65

Class

AmountFormattingForm
Configures amount formatting.

Namespace

Drupal\currency\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('currency.amount_formatting');
  $options = array();
  foreach ($this->currencyAmountFormatterManager
    ->getDefinitions() as $plugin_id => $plugin_definition) {
    $options[$plugin_id] = $plugin_definition['label'];
  }
  $form['default_plugin_id'] = array(
    '#default_value' => $config
      ->get('plugin_id'),
    '#options' => $options,
    '#process' => [
      [
        Radios::class,
        'processRadios',
      ],
      [
        $this,
        'processPluginOptions',
      ],
    ],
    '#title' => $this
      ->t('Default amount formatter'),
    '#type' => 'radios',
  );
  return parent::buildForm($form, $form_state);
}