You are here

protected function Section::valueForm in Workbench Access 8

Overrides \Drupal\views\Plugin\views\filter\ManyToOne::valueForm().

Our options are user-based. Filter out any not allowed by the view configuration.

Overrides ManyToOne::valueForm

File

src/Plugin/views/filter/Section.php, line 130

Class

Section
Filter by assigned section.

Namespace

Drupal\workbench_access\Plugin\views\filter

Code

protected function valueForm(&$form, FormStateInterface $form_state) {
  parent::valueForm($form, $form_state);
  if (!$form_state
    ->get('exposed')) {
    $this->helper
      ->buildOptionsForm($form, $form_state);
  }
  else {
    $options = $this->valueOptions;
    $exposed_options = [];
    $empty = [
      0 => $this
        ->t('All'),
    ];
    if ($this->options['value'] != $empty && !isset($this->options['value']['all'])) {
      foreach ($options as $key => $value) {
        if (!isset($this->options['value'][$key])) {
          unset($options[$key]);
        }
      }
    }
    $form['value']['#options'] = $options;
  }
}