You are here

protected function ContextualBundle::valueForm in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/filter/ContextualBundle.php \Drupal\entity_browser\Plugin\views\filter\ContextualBundle::valueForm()

Options form subform for setting options.

This should be overridden by all child classes and it must define $form['value']

Overrides InOperator::valueForm

See also

buildOptionsForm()

File

src/Plugin/views/filter/ContextualBundle.php, line 216

Class

ContextualBundle
Filter class which allows filtering by entity bundles.

Namespace

Drupal\entity_browser\Plugin\views\filter

Code

protected function valueForm(&$form, FormStateInterface $form_state) {
  parent::valueForm($form, $form_state);

  // Disable element on config form.
  if ($this->requestStack
    ->getCurrentRequest()->attributes
    ->get('_route') == 'views_ui.form_handler') {
    $form['value']['#default_value'] = array_combine(array_keys($form['value']['#options']), array_keys($form['value']['#options']));
    $form['value']['#disabled'] = TRUE;
    $form['value']['#description'] = $this
      ->t('You cannot edit this list because the options update in response to entity browser context.');
  }
  elseif (!empty($this->value) && count($this->value) === 1) {
    $form['value'] = [
      '#type' => 'hidden',
      '#value' => array_values($this->value)[0],
    ];
  }
}