function EntityReference::valueFormAddAutocomplete
Adds an autocomplete element to the form.
Parameters
array $form: Associative array containing the structure of the form, passed by reference.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 call to EntityReference::valueFormAddAutocomplete()
- EntityReference::valueForm in core/
modules/ views/ src/ Plugin/ views/ filter/ EntityReference.php - Options form subform for setting options.
File
-
core/
modules/ views/ src/ Plugin/ views/ filter/ EntityReference.php, line 466
Class
- EntityReference
- Filters a view by entity references.
Namespace
Drupal\views\Plugin\views\filterCode
protected function valueFormAddAutocomplete(array &$form, FormStateInterface $form_state) : void {
$referenced_type = $this->getReferencedEntityType();
$form['value'] = [
'#title' => $this->t('Select %entity_types', [
'%entity_types' => $referenced_type->getPluralLabel(),
]),
'#type' => 'entity_autocomplete',
'#default_value' => EntityAutocomplete::getEntityLabels($this->getDefaultSelectedEntities()),
'#tags' => TRUE,
'#process_default_value' => FALSE,
'#target_type' => $referenced_type->id(),
'#selection_handler' => $this->options['sub_handler'],
'#selection_settings' => $this->options['sub_handler_settings'],
// Validation is done by validateExposed().
'#validate_reference' => FALSE,
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.