You are here

protected function KeywordId::valueForm in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/src/Plugin/views/filter/KeywordId.php \Drupal\bibcite_entity\Plugin\views\filter\KeywordId::valueForm()

Options form subform for setting options.

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

Overrides ManyToOne::valueForm

See also

buildOptionsForm()

File

modules/bibcite_entity/src/Plugin/views/filter/KeywordId.php, line 31

Class

KeywordId
Filter handler for keywords.

Namespace

Drupal\bibcite_entity\Plugin\views\filter

Code

protected function valueForm(&$form, FormStateInterface $form_state) {
  $keywords = $this->value ? Keyword::loadMultiple($this->value) : [];
  $default_value = EntityAutocomplete::getEntityLabels($keywords);
  $form['value'] = [
    '#type' => 'entity_autocomplete',
    '#title' => $this
      ->t('Keywords'),
    '#description' => $this
      ->t('Enter a comma separated list of keywords.'),
    '#target_type' => 'bibcite_keyword',
    '#tags' => TRUE,
    '#default_value' => $default_value,
    '#process_default_value' => $this
      ->isExposed(),
  ];
  $user_input = $form_state
    ->getUserInput();
  if ($form_state
    ->get('exposed') && !isset($user_input[$this->options['expose']['identifier']])) {
    $user_input[$this->options['expose']['identifier']] = $default_value;
    $form_state
      ->setUserInput($user_input);
  }
}