public function Populate::validate in Views filters populate 8
Validate that the plugin is correct and can be saved.
Return value
An array of error strings to tell the user what is wrong with this plugin.
Overrides FilterPluginBase::validate
File
- src/
Plugin/ views/ filter/ Populate.php, line 188
Class
- Populate
- Filter handler which allows to search on multiple fields.
Namespace
Drupal\views_filters_populate\Plugin\views\filterCode
public function validate() {
$errors = parent::validate();
$filters = $this->displayHandler
->getHandlers('filter');
// Only perform these validatiosn if the query is not being built
// @see ViewExecutable::build()
if (empty($this->view->build_info)) {
foreach ($this->options['filters'] as $id) {
// Make sure are populate filters are properly configured/available
if (!isset($filters[$id])) {
$errors[] = $this
->t('%display: Filter %filter set in %name is not available.', [
'%filter' => $id,
'%name' => $this
->adminLabel(),
'%display' => $this->displayHandler->display['display_title'],
]);
}
else {
$filter = $filters[$id];
if ($filter->options['exposed']) {
$errors[] = $this
->t('%display: Filter %filter set in %name is not usable when exposed.', [
'%filter' => $filter
->adminLabel(),
'%name' => $this
->adminLabel(),
'%display' => $this->displayHandler->display['display_title'],
]);
}
}
}
}
return $errors;
}