reverted: --- b/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php +++ a/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php @@ -21,7 +21,7 @@ * * @var array */ + public static $testViews = array('test_exposed_form_buttons', 'test_exposed_block'); - public static $testViews = array('test_exposed_form_buttons', 'test_exposed_block', 'test_exposed_form'); /** * Modules to enable. @@ -174,20 +174,4 @@ return drupal_clean_css_identifier('views-exposed-form-' . $view->storage->id() . '-' . $view->current_display); } - /** - * Tests a view which is rendered after a form with a validation error. - */ - public function testFormErrorWithExposedForm() { - $nodes = array(); - $nodes[] = $this->drupalCreateNode(); - $nodes[] = $this->drupalCreateNode(); - - $this->drupalGet('test-form'); - $this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered before submitting the normal form.'); - - $this->drupalPost(NULL, array(), t('Submit')); - $this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered after submitting the normal form.'); - - } - } reverted: --- b/core/modules/views/lib/Drupal/views/ViewExecutable.php +++ a/core/modules/views/lib/Drupal/views/ViewExecutable.php @@ -1076,16 +1076,8 @@ if ($this->display_handler->usesExposed()) { $exposed_form = $this->display_handler->getPlugin('exposed_form'); - // (1) Record the errors before rendering the exposed form widgets - $errors_before = \Drupal::formBuilder()->getAnyErrors(); $this->exposed_widgets = $exposed_form->renderExposedForm(); + if (\Drupal::formBuilder()->getAnyErrors() || !empty($this->build_info['abort'])) { - // (2) Record the errors after rendering the exposed form widgets. - $errors_after = \Drupal::formBuilder()->getAnyErrors(); - // Find out if the validation of any of the elements in the exposed form - // has failed by comparing (1) and (2) above. Don't mess with the view - // otherwise. - $exposed_errors = count($errors_after) > count($errors_before); - if ($exposed_errors || !empty($this->build_info['abort'])) { $this->built = TRUE; // Don't execute the query, $form_state, but rendering will still be executed to display the empty text. $this->executed = TRUE; only in patch2: unchanged: --- a/core/modules/views/src/Tests/Plugin/ExposedFormTest.php +++ b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php @@ -21,7 +21,7 @@ class ExposedFormTest extends ViewTestBase { * * @var array */ - public static $testViews = array('test_exposed_form_buttons', 'test_exposed_block'); + public static $testViews = array('test_exposed_form_buttons', 'test_exposed_block', 'test_exposed_form'); /** * Modules to enable. @@ -198,4 +198,20 @@ protected function getExpectedExposedFormId(ViewExecutable $view) { return drupal_clean_css_identifier('views-exposed-form-' . $view->storage->id() . '-' . $view->current_display); } + /** + * Tests a view which is rendered after a form with a validation error. + */ + public function testFormErrorWithExposedForm() { + $nodes = array(); + $nodes[] = $this->drupalCreateNode(); + $nodes[] = $this->drupalCreateNode(); + + $this->drupalGet('test-form'); + $this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered before submitting the normal form.'); + + $this->drupalPost(NULL, array(), t('Submit')); + $this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered after submitting the normal form.'); + + } + } only in patch2: unchanged: --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -1076,8 +1076,16 @@ public function build($display_id = NULL) { if ($this->display_handler->usesExposed()) { $exposed_form = $this->display_handler->getPlugin('exposed_form'); + // (1) Record the errors before rendering the exposed form widgets + $errors_before = \Drupal::formBuilder()->getAnyErrors(); $this->exposed_widgets = $exposed_form->renderExposedForm(); - if (\Drupal::formBuilder()->getAnyErrors() || !empty($this->build_info['abort'])) { + // (2) Record the errors after rendering the exposed form widgets. + $errors_after = \Drupal::formBuilder()->getAnyErrors(); + // Find out if the validation of any of the elements in the exposed form + // has failed by comparing (1) and (2) above. Don't mess with the view + // otherwise. + $exposed_errors = count($errors_after) > count($errors_before); + if ($exposed_errors || !empty($this->build_info['abort'])) { $this->built = TRUE; // Don't execute the query, $form_state, but rendering will still be executed to display the empty text. $this->executed = TRUE;