Skip to content
Snippets Groups Projects
Verified Commit 5370c539 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2916682 by Matroskeen: Defaults not working for grouped filter with multiple selections

(cherry picked from commit 25a2823e)
parent c39e9dc1
Branches
Tags
19 merge requests!8357Issue #2994000 by Lendude, Pasqualle, quietone, pameeela: Notice in logs when...,!4488Issue #3376281: Random machine names no longer need to be wrapped in strtolower(),!3149Issue #3282285: Email "" does not comply with addr-spec of RFC 2822,!3000Issue #793660: Check for failure of hook_install,!2940Issue #3320240: Entity count query returns a string instead of int,!2937Issue #3315245: Order of languages overrides default language fallback,!2877Issue #3056652 by yogeshmpawar, mashermike, aalin, ranjith_kumar_k_u: Link...,!2804URL of image field formatter use absolute URL option.,!2749Issue #3309024: Focus on the wrong submit button after AJAX submit,!2692Issue #3284010 by _shY, mherchel, Abhijith S: "Create content" link within...,!2608Issue #2430379 by quietone, znerol, larowlan: Add explicit test for session...,!2575Issue #3198340 by alexpott, xjm, cilefen, Mile23, mmjvb, catch, longwave, mfb,...,!2555Issue #3277148 by rpayanm, andregp, joachim, Farnoosh, Athrylith, Jingting:...,!2554Issue #3277148 by rpayanm, andregp, joachim, Farnoosh, Athrylith, Jingting:...,!2539Issue #3299806 by BenStallings: Include uuid field in d7_node migration, if present.,!1627Issue #3082958: Add gitignore(s) to composer-ready project templates,!1014Issue #3226806: Move filter implementations from filter.module to plugin classes,!939Issue #2971209: Allow the MediaLibraryUiBuilder service to use an alternative view display,!88Issue #3163299: Ajax exposed filters not working for multiple instances of the same Views block placed on one page
...@@ -882,7 +882,7 @@ public function groupForm(&$form, FormStateInterface $form_state) { ...@@ -882,7 +882,7 @@ public function groupForm(&$form, FormStateInterface $form_state) {
} }
unset($form[$value]['#default_value']); unset($form[$value]['#default_value']);
$user_input = $form_state->getUserInput(); $user_input = $form_state->getUserInput();
if (empty($user_input)) { if (empty($user_input[$value])) {
$user_input[$value] = $this->group_info; $user_input[$value] = $this->group_info;
$form_state->setUserInput($user_input); $form_state->setUserInput($user_input);
} }
......
...@@ -324,12 +324,27 @@ public function testExposedGroupedFilter() { ...@@ -324,12 +324,27 @@ public function testExposedGroupedFilter() {
'options[group_info][group_items][2][value][article]' => 'article', 'options[group_info][group_items][2][value][article]' => 'article',
'options[group_info][group_items][3][title]' => '3rd', 'options[group_info][group_items][3][title]' => '3rd',
'options[group_info][group_items][3][value][page]' => 'page', 'options[group_info][group_items][3][value][page]' => 'page',
'options[group_info][default_group]' => '3',
]; ];
// Apply the filter settings. // Apply the filter settings.
$this->submitForm($edit, 'Apply'); $this->submitForm($edit, 'Apply');
// Check that the view is saved without errors. // Check that the view is saved without errors.
$this->submitForm([], 'Save'); $this->submitForm([], 'Save');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
// Check the default filter value.
$this->drupalGet('test_exposed_admin_ui');
$this->assertSession()->fieldValueEquals('type', '3');
// Enable "Allow multiple selections" option and set a default group.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$edit['options[group_info][multiple]'] = 1;
$edit['options[group_info][default_group_multiple][1]'] = 1;
$this->submitForm($edit, 'Apply');
$this->submitForm([], 'Save');
// Check the default filter values again.
$this->drupalGet('test_exposed_admin_ui');
$this->assertSession()->checkboxChecked('type[1]');
$this->assertSession()->checkboxNotChecked('type[2]');
$this->assertSession()->checkboxNotChecked('type[3]');
// Click the Expose filter button. // Click the Expose filter button.
$this->drupalGet('admin/structure/views/nojs/add-handler/test_exposed_admin_ui/default/filter'); $this->drupalGet('admin/structure/views/nojs/add-handler/test_exposed_admin_ui/default/filter');
...@@ -348,18 +363,33 @@ public function testExposedGroupedFilter() { ...@@ -348,18 +363,33 @@ public function testExposedGroupedFilter() {
'options[group_info][group_items][2][value]' => 1, 'options[group_info][group_items][2][value]' => 1,
'options[group_info][group_items][3][title]' => 'Unpublished', 'options[group_info][group_items][3][title]' => 'Unpublished',
'options[group_info][group_items][3][value]' => 0, 'options[group_info][group_items][3][value]' => 0,
'options[group_info][default_group]' => 2,
]; ];
// Apply the filter settings. // Apply the filter settings.
$this->submitForm($edit, 'Apply'); $this->submitForm($edit, 'Apply');
// Check that the view is saved without errors. // Check that the view is saved without errors.
$this->submitForm([], 'Save'); $this->submitForm([], 'Save');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status'); $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status');
// Assert the same settings defined before still are there. // Assert the same settings defined before still are there.
$this->assertSession()->checkboxChecked('edit-options-group-info-group-items-1-value-all'); $this->assertSession()->checkboxChecked('edit-options-group-info-group-items-1-value-all');
$this->assertSession()->checkboxChecked('edit-options-group-info-group-items-2-value-1'); $this->assertSession()->checkboxChecked('edit-options-group-info-group-items-2-value-1');
$this->assertSession()->checkboxChecked('edit-options-group-info-group-items-3-value-0'); $this->assertSession()->checkboxChecked('edit-options-group-info-group-items-3-value-0');
// Check the default filter value.
$this->drupalGet('test_exposed_admin_ui');
$this->assertSession()->fieldValueEquals('status', '2');
// Enable "Allow multiple selections" option and set a default group.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status');
$edit['options[group_info][multiple]'] = 1;
$edit['options[group_info][default_group_multiple][3]'] = 1;
$this->submitForm($edit, 'Apply');
$this->submitForm([], 'Save');
// Check the default filter value again.
$this->drupalGet('test_exposed_admin_ui');
$this->assertSession()->checkboxNotChecked('status[1]');
$this->assertSession()->checkboxNotChecked('status[2]');
$this->assertSession()->checkboxChecked('status[3]');
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment