public function SynonymsEntity::validateExposed in Synonyms 2.0.x
Same name and namespace in other branches
- 8 synonyms_views_filter/src/Plugin/views/filter/SynonymsEntity.php \Drupal\synonyms_views_filter\Plugin\views\filter\SynonymsEntity::validateExposed()
Validate the exposed handler form.
Overrides HandlerBase::validateExposed
File
- modules/
synonyms_views_filter/ src/ Plugin/ views/ filter/ SynonymsEntity.php, line 167
Class
- SynonymsEntity
- Filter entity by its name or one of its synonyms.
Namespace
Drupal\synonyms_views_filter\Plugin\views\filterCode
public function validateExposed(&$form, FormStateInterface $form_state) {
parent::validateExposed($form, $form_state);
$identifier = $this->options['expose']['identifier'];
$target_ids = $form_state
->getValue($identifier);
switch ($this->operator) {
case 'IN':
$target_ids = array_map(function ($item) {
return $item['target_id'];
}, $target_ids);
break;
case '=':
$target_ids = $target_ids['target_id'];
break;
}
$form_state
->setValue($identifier, $target_ids);
}