function WizardPluginBase::buildFilters
Same name in other branches
- 9 core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php \Drupal\views\Plugin\views\wizard\WizardPluginBase::buildFilters()
- 10 core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php \Drupal\views\Plugin\views\wizard\WizardPluginBase::buildFilters()
- 11.x core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php \Drupal\views\Plugin\views\wizard\WizardPluginBase::buildFilters()
Builds the form structure for selecting the view's filters.
By default, this adds "of type" and "tagged with" filters (when they are available).
2 calls to WizardPluginBase::buildFilters()
- Node::buildFilters in core/
modules/ node/ src/ Plugin/ views/ wizard/ Node.php - Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::buildFilters().
- WizardPluginBase::buildForm in core/
modules/ views/ src/ Plugin/ views/ wizard/ WizardPluginBase.php - Form callback to build other elements in the "show" form.
1 method overrides WizardPluginBase::buildFilters()
- Node::buildFilters in core/
modules/ node/ src/ Plugin/ views/ wizard/ Node.php - Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::buildFilters().
File
-
core/
modules/ views/ src/ Plugin/ views/ wizard/ WizardPluginBase.php, line 624
Class
- WizardPluginBase
- Base class for Views wizard plugins.
Namespace
Drupal\views\Plugin\views\wizardCode
protected function buildFilters(&$form, FormStateInterface $form_state) {
module_load_include('inc', 'views_ui', 'admin');
$bundles = $this->bundleInfoService
->getBundleInfo($this->entityTypeId);
// If the current base table support bundles and has more than one (like user).
if (!empty($bundles) && $this->entityType && $this->entityType
->hasKey('bundle')) {
// Get all bundles and their human readable names.
$options = [
'all' => $this->t('All'),
];
foreach ($bundles as $type => $bundle) {
$options[$type] = $bundle['label'];
}
$form['displays']['show']['type'] = [
'#type' => 'select',
'#title' => $this->t('of type'),
'#options' => $options,
];
$selected_bundle = static::getSelected($form_state, [
'show',
'type',
], 'all', $form['displays']['show']['type']);
$form['displays']['show']['type']['#default_value'] = $selected_bundle;
// Changing this dropdown updates the entire content of $form['displays']
// via AJAX, since each bundle might have entirely different fields
// attached to it, etc.
views_ui_add_ajax_trigger($form['displays']['show'], 'type', [
'displays',
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.