You are here

public function MediaDirectoriesConfigForm::buildForm in Media Directories 3.x

Same name and namespace in other branches
  1. 8 src/Form/MediaDirectoriesConfigForm.php \Drupal\media_directories\Form\MediaDirectoriesConfigForm::buildForm()
  2. 2.x src/Form/MediaDirectoriesConfigForm.php \Drupal\media_directories\Form\MediaDirectoriesConfigForm::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 ConfigFormBase::buildForm

File

src/Form/MediaDirectoriesConfigForm.php, line 61

Class

MediaDirectoriesConfigForm
Media directories configuration form.

Namespace

Drupal\media_directories\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('media_directories.settings');
  $vocabularies = $this->entityTypeManager
    ->getStorage('taxonomy_vocabulary')
    ->loadMultiple();
  $options = [];
  $options[''] = $this
    ->t('- None -');
  foreach ($vocabularies as $vocabulary) {
    $options[$vocabulary
      ->id()] = $vocabulary
      ->label();
  }
  $form['directory_taxonomy'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Taxonomy'),
    '#description' => $this
      ->t('Select taxonomy for directory structure.'),
    '#options' => $options,
    '#default_value' => $config
      ->get('directory_taxonomy'),
  ];
  return parent::buildForm($form, $form_state);
}