Skip to content
Snippets Groups Projects

Views Between Filter

Files
7
@@ -59,7 +59,15 @@ class ViewsFilters extends DataProducerPluginBase {
foreach ($exposed_filters as $filter) {
$info = $filter->exposedInfo();
$form_element = $view->exposed_widgets[$info['value']];
$identifier = $info['value'];
$wrapper = !empty($view->exposed_widgets[$identifier . '_wrapper'])
? $identifier . '_wrapper'
: FALSE;
$form_element = $wrapper
? $view->exposed_widgets[$wrapper][$identifier]
: $view->exposed_widgets[$identifier];
$required = $filter->isAGroup()
? !$filter->options['group_info']['optional']
@@ -80,15 +88,14 @@ class ViewsFilters extends DataProducerPluginBase {
// Replace with the views exposed input.
$exposed_input = $view->getExposedInput();
$value = $exposed_input[$info['value']] ?? $default_value;
$value = $exposed_input[$identifier] ?? $default_value;
// Reshape default data a bit to make it a bit more consistent.
// Ensure values are strings.
if (is_array($value)) {
$value = array_map('strval', array_values($value));
$value = $multiple ? $value : current($value);
$value = array_map('strval', $value);
}
// Any added attributes except for the ones we don't want.
// Ignore some common attributes.
$ignored_attributes = [
'data-drupal-selector',
'id',
@@ -111,11 +118,12 @@ class ViewsFilters extends DataProducerPluginBase {
$results[] = [
'id' => $info['value'],
'plugin' => $filter->getPluginId(),
'operator' => $filter->operator,
'type' => $form_element['#type'] ?? 'unknown',
'label' => $info['label'] ?: NULL,
'description' => $info['description'] ?: NULL,
'value' => $value,
'options' => $options ?? NULL ?: NULL,
'options' => $options,
'required' => $required,
'multiple' => $multiple,
'attributes' => $attributes,
Loading