You are here

public function KeywordSettingsForm::buildForm in Alinks 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

src/Form/KeywordSettingsForm.php, line 100

Class

KeywordSettingsForm
Class KeywordSettingsForm.

Namespace

Drupal\alinks\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $form['display'] = array(
    '#type' => 'details',
    '#title' => $this
      ->t('Configure the displays on which alinks should be used'),
    '#open' => TRUE,
  );
  $form['display'] += $this
    ->buildTable($form_state);
  $form['display'] += $this
    ->buildAddNew($form_state);
  $vocabularies = $this
    ->configFactory()
    ->getEditable('alinks.settings')
    ->get('vocabularies');
  $form['settings'] = array(
    '#type' => 'details',
    '#title' => $this
      ->t('Replace taxonomy terms'),
    '#open' => TRUE,
  );
  $form['settings']['vocabularies'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Vocabularies'),
    '#default_value' => $vocabularies,
  ];
  $vocabularies = $this->entityTypeManager
    ->getStorage('taxonomy_vocabulary')
    ->loadMultiple();
  foreach ($vocabularies as $vocabulary) {
    $form['settings']['vocabularies']['#options'][$vocabulary
      ->id()] = $vocabulary
      ->label();
  }
  return $form;
}