protected function KeywordId::valueForm in Bibliography & Citation 2.0.x
Same name and namespace in other branches
- 8 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\filterCode
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);
}
}