Loading core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php +5 −2 Changes for core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php: 5 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -262,8 +262,11 @@ public function exposedFormAlter(&$form, FormStateInterface $form_state) { } $all_exposed = array_merge($exposed_sorts, $exposed_filters); // Set the access to FALSE if there is no exposed input. if (!array_intersect_key($all_exposed, $this->view->getExposedInput())) { // Don't display the reset button if there is no input in the exposed // form or while using the default sort. $exposed_input = $this->view->getExposedInput(); $reset = array_intersect_key($all_exposed, $exposed_input) || isset($exposed_input['order']) || isset($exposed_input['sort']); if (!$reset) { $form['actions']['reset']['#access'] = FALSE; } } Loading core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php +6 Changes for core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -214,6 +214,12 @@ public function testResetButton(): void { $this->drupalGet('test_exposed_form_buttons'); $this->assertSession()->fieldNotExists('edit-reset'); // Verify Reset button appears with just order + sort keys. $this->drupalGet('test_exposed_form_buttons', [ 'query' => ['order' => 'id', 'sort' => 'asc'], ]); $this->assertSession()->buttonExists('Reset'); $this->drupalGet('test_exposed_form_buttons', ['query' => ['type' => 'article']]); // Test that the type has been set. $this->assertSession()->fieldValueEquals('edit-type', 'article'); Loading Loading
core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php +5 −2 Changes for core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php: 5 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -262,8 +262,11 @@ public function exposedFormAlter(&$form, FormStateInterface $form_state) { } $all_exposed = array_merge($exposed_sorts, $exposed_filters); // Set the access to FALSE if there is no exposed input. if (!array_intersect_key($all_exposed, $this->view->getExposedInput())) { // Don't display the reset button if there is no input in the exposed // form or while using the default sort. $exposed_input = $this->view->getExposedInput(); $reset = array_intersect_key($all_exposed, $exposed_input) || isset($exposed_input['order']) || isset($exposed_input['sort']); if (!$reset) { $form['actions']['reset']['#access'] = FALSE; } } Loading
core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php +6 Changes for core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -214,6 +214,12 @@ public function testResetButton(): void { $this->drupalGet('test_exposed_form_buttons'); $this->assertSession()->fieldNotExists('edit-reset'); // Verify Reset button appears with just order + sort keys. $this->drupalGet('test_exposed_form_buttons', [ 'query' => ['order' => 'id', 'sort' => 'asc'], ]); $this->assertSession()->buttonExists('Reset'); $this->drupalGet('test_exposed_form_buttons', ['query' => ['type' => 'article']]); // Test that the type has been set. $this->assertSession()->fieldValueEquals('edit-type', 'article'); Loading