You are here

public function SettingsForm::buildForm in Config Distro 8

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

modules/config_distro_ignore/src/Form/SettingsForm.php, line 69

Class

SettingsForm
Provides a setting UI for Config Distro Ignore.

Namespace

Drupal\config_distro_ignore\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $settings = $this
    ->config('config_distro_ignore.settings');
  $form['all_collections'] = [
    '#type' => 'textarea',
    '#rows' => 25,
    '#title' => $this
      ->t('Configuration for all collections'),
    '#default_value' => implode(PHP_EOL, $settings
      ->get('all_collections')),
    '#size' => 20,
  ];
  $form['default_collection'] = [
    '#type' => 'textarea',
    '#rows' => 25,
    '#title' => $this
      ->t('Configuration for the default collection'),
    '#default_value' => implode(PHP_EOL, $settings
      ->get('default_collection')),
    '#size' => 20,
  ];
  foreach ($this->distroStorage
    ->getAllCollectionNames() as $collection) {
    $key = 'custom_collections.' . $collection;
    $form[strtr($key, [
      '.' => '_',
    ])] = [
      '#type' => 'textarea',
      '#rows' => 25,
      '#title' => $this
        ->t('Configuration for the @collection collection', [
        '@collection' => $collection,
      ]),
      '#default_value' => implode(PHP_EOL, $settings
        ->get($key)),
      '#size' => 20,
    ];
  }
  return parent::buildForm($form, $form_state);
}