You are here

public function CurrentContext::buildOptionsForm in Config Pages 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/views/argument_default/CurrentContext.php \Drupal\config_pages\Plugin\views\argument_default\CurrentContext::buildOptionsForm()

Provide the default form for setting options.

Overrides ArgumentDefaultPluginBase::buildOptionsForm

File

src/Plugin/views/argument_default/CurrentContext.php, line 34

Class

CurrentContext
Default argument plugin to use the current context value.

Namespace

Drupal\config_pages\Plugin\views\argument_default

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);

  // Get all available ConfigPages types and prepare options list.
  $config_pages_types = ConfigPagesType::loadMultiple();
  $options = [];
  foreach ($config_pages_types as $cp_type) {
    $id = $cp_type
      ->id();
    $label = $cp_type
      ->label();
    $options[$id] = $label;
  }
  $form['config_page_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Select ConfigPage type to get Context for.'),
    '#options' => $options,
    '#default_value' => isset($this->options['config_page_type']) ? $this->options['config_page_type'] : '',
  ];
}