You are here

public function DefaultForm::buildForm in Toolbar Visibility 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/DefaultForm.php, line 39
Contains Drupal\toolbar_visibility\Form\DefaultForm.

Class

DefaultForm
Class DefaultForm.

Namespace

Drupal\toolbar_visibility\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('toolbar_visibility.default_config');
  $themes = \Drupal::config('toolbar_visibility.default_config')
    ->get('toolbar_visibility_theme');
  $list_themes = \Drupal::service('theme_handler')
    ->listInfo();
  $all_themes = [];
  foreach ($list_themes as $list) {
    $all_themes[$list
      ->getName()] = $list
      ->getName();
  }
  $form['toolbar_visibility_theme'] = array(
    '#type' => 'select',
    '#title' => t('Select theme(s) where you want to remove Toolbar'),
    '#multiple' => TRUE,
    '#options' => $all_themes,
    '#default_value' => \Drupal::config('toolbar_visibility.default_config')
      ->get('toolbar_visibility_theme'),
  );
  return parent::buildForm($form, $form_state);
}