You are here

public function Populate::buildOptionsForm in Views filters populate 8

Provide the basic form which calls through to subforms. If overridden, it is best to call through to the parent, or to at least make sure all of the functions in this form are called.

Overrides FilterPluginBase::buildOptionsForm

File

src/Plugin/views/filter/Populate.php, line 115

Class

Populate
Filter handler which allows to search on multiple fields.

Namespace

Drupal\views_filters_populate\Plugin\views\filter

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $options = [];
  foreach ($this->displayHandler
    ->getHandlers('filter') as $name => $filter) {
    if ($filter != $this && $this
      ->isFilterSupported($filter) && !$filter->options['exposed']) {
      $options[$name] = $filter
        ->adminLabel(TRUE);
    }
  }
  $form['filters'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Available filters'),
    '#description' => $this
      ->t("Only supported <i><b>non exposed</b></i> filters that accept a string value are shown here."),
    '#multiple' => TRUE,
    '#options' => $options,
    '#default_value' => $this->options['filters'],
  ];
}