Commit b8f580bf authored by alexpott's avatar alexpott Committed by larowlan

Issue #2884296 by Lendude, anmolgoyal74, kallehauge, Etroid, Nick Hope, dww,...

Issue #2884296 by Lendude, anmolgoyal74, kallehauge, Etroid, Nick Hope, dww, xjm, Dakwamine, wturrell, Rob Holmes, John Pitcairn: Undefined index notice when renaming grouped filter identifiers

(cherry picked from commit 1ab63529)
parent 55b1150d
......@@ -1347,7 +1347,7 @@ public function convertExposedInput(&$input, $selected_group_id = NULL) {
// Value can be optional, For example for 'empty' and 'not empty' filters.
if (isset($this->options['group_info']['group_items'][$selected_group]['value']) && $this->options['group_info']['group_items'][$selected_group]['value'] !== '') {
$input[$this->options['expose']['identifier']] = $this->options['group_info']['group_items'][$selected_group]['value'];
$input[$this->options['group_info']['identifier']] = $this->options['group_info']['group_items'][$selected_group]['value'];
}
$this->options['expose']['use_operator'] = TRUE;
......@@ -1439,7 +1439,12 @@ public function acceptExposedInput($input) {
}
if (!empty($this->options['expose']['identifier'])) {
$value = $input[$this->options['expose']['identifier']];
if ($this->options['is_grouped']) {
$value = $input[$this->options['group_info']['identifier']];
}
else {
$value = $input[$this->options['expose']['identifier']];
}
// Various ways to check for the absence of non-required input.
if (empty($this->options['expose']['required'])) {
......
......@@ -164,6 +164,39 @@ public function testFilterNotInOperatorGroupedExposedSimple() {
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}
/**
* Tests that we can safely change the identifier on a grouped filter.
*/
public function testFilterGroupedChangedIdentifier() {
$filters = $this->getGroupedExposedFilters();
$view = Views::getView('test_view');
$filters['age']['group_info']['default_group'] = 2;
$filters['age']['group_info']['identifier'] = 'not-age';
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('filters', $filters);
$this->executeView($view);
$expected_result = [
[
'name' => 'John',
'age' => 25,
],
[
'name' => 'George',
'age' => 27,
],
[
'name' => 'Ringo',
'age' => 28,
],
];
$this->assertCount(3, $view->result);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}
protected function getGroupedExposedFilters() {
$filters = [
'age' => [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment