Issue #2916682 by Matroskeen: Defaults not working for grouped filter with multiple selections
parent
79c009db1d
commit
25a2823e10
|
@ -882,7 +882,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
|
|||
}
|
||||
unset($form[$value]['#default_value']);
|
||||
$user_input = $form_state->getUserInput();
|
||||
if (empty($user_input)) {
|
||||
if (empty($user_input[$value])) {
|
||||
$user_input[$value] = $this->group_info;
|
||||
$form_state->setUserInput($user_input);
|
||||
}
|
||||
|
|
|
@ -324,12 +324,27 @@ class ExposedFormUITest extends UITestBase {
|
|||
'options[group_info][group_items][2][value][article]' => 'article',
|
||||
'options[group_info][group_items][3][title]' => '3rd',
|
||||
'options[group_info][group_items][3][value][page]' => 'page',
|
||||
'options[group_info][default_group]' => '3',
|
||||
];
|
||||
// Apply the filter settings.
|
||||
$this->submitForm($edit, 'Apply');
|
||||
// Check that the view is saved without errors.
|
||||
$this->submitForm([], 'Save');
|
||||
$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.
|
||||
$this->drupalGet('admin/structure/views/nojs/add-handler/test_exposed_admin_ui/default/filter');
|
||||
|
@ -348,18 +363,33 @@ class ExposedFormUITest extends UITestBase {
|
|||
'options[group_info][group_items][2][value]' => 1,
|
||||
'options[group_info][group_items][3][title]' => 'Unpublished',
|
||||
'options[group_info][group_items][3][value]' => 0,
|
||||
'options[group_info][default_group]' => 2,
|
||||
];
|
||||
// Apply the filter settings.
|
||||
$this->submitForm($edit, 'Apply');
|
||||
// Check that the view is saved without errors.
|
||||
$this->submitForm([], 'Save');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status');
|
||||
// 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-2-value-1');
|
||||
$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]');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue