private function VeflBasic::getRegionElements in Views exposed form layout 8
Parameters
$layout_id:
array $layouts:
Return value
array
1 call to VeflBasic::getRegionElements()
- VeflBasic::buildOptionsForm in src/
Plugin/ views/ exposed_form/ VeflBasic.php - Provide a form to edit options for this plugin.
File
- src/
Plugin/ views/ exposed_form/ VeflBasic.php, line 72
Class
- VeflBasic
- Exposed form plugin that provides a basic exposed form with layout.
Namespace
Drupal\vefl\Plugin\views\exposed_formCode
private function getRegionElements($layout_id, $layouts = []) {
$element = [
'#prefix' => '<div id="edit-block-region-wrapper">',
'#suffix' => '</div>',
];
// Outputs regions selectbox for each filter.
$types = [
'filters' => $this->view->display_handler
->getHandlers('filter'),
'actions' => Vefl::getFormActions(),
];
// Adds additional action for BEF combined sort. @todo
// if (!empty($vars['widgets']['sort-sort_bef_combine'])) {
// $actions[] = 'sort-sort_bef_combine';
// }
$regions = [];
foreach ($layouts[$layout_id]['regions'] as $region_id => $region) {
$regions[$region_id] = $region['label'];
}
foreach ($types as $type => $fields) {
foreach ($fields as $id => $filter) {
if ($type == 'filters') {
if (!$filter->options['exposed']) {
continue;
}
$filter = $filter->definition['title'];
}
$element[$id] = [
'#type' => 'select',
'#title' => $filter,
'#options' => $regions,
];
// Set default region for chosen layout.
if (!empty($this->options['layout']['widget_region'][$id]) && !empty($regions[$this->options['layout']['widget_region'][$id]])) {
$element[$id]['#default_value'] = $this->options['layout']['widget_region'][$id];
}
}
}
return $element;
}