public function YieldToArgumentTrait::buildExposedForm in Lightning Core 8
Same name and namespace in other branches
- 8.5 src/YieldToArgumentTrait.php \Drupal\lightning_core\YieldToArgumentTrait::buildExposedForm()
- 8.2 src/YieldToArgumentTrait.php \Drupal\lightning_core\YieldToArgumentTrait::buildExposedForm()
- 8.3 src/YieldToArgumentTrait.php \Drupal\lightning_core\YieldToArgumentTrait::buildExposedForm()
- 8.4 src/YieldToArgumentTrait.php \Drupal\lightning_core\YieldToArgumentTrait::buildExposedForm()
File
- src/
YieldToArgumentTrait.php, line 15
Class
- YieldToArgumentTrait
- Allows exposed an Views filter to disappear if an argument is present.
Namespace
Drupal\lightning_coreCode
public function buildExposedForm(&$form, FormStateInterface $form_state) {
parent::buildExposedForm($form, $form_state);
if (empty($this->options['exposed'])) {
return;
}
if (empty($this->options['expose']['argument'])) {
return;
}
$argument = $this->options['expose']['argument'];
$argument = $this->view->argument[$argument];
/** @var \Drupal\views\Plugin\views\argument\ArgumentPluginBase $argument */
$value = $argument
->getValue();
$key = $this->options['expose']['identifier'];
$form[$key]['#access'] = is_null($value) || $argument
->isException($value);
}