diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php index 16e2cd18d7e87b5b9f633be0f2a75329c66abe0b..9272d12ce5d1995d67462fb639327de388624317 100644 --- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php +++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php @@ -133,12 +133,6 @@ public function renderExposedForm($block = FALSE) { } $form = \Drupal::formBuilder()->buildForm('\Drupal\views\Form\ViewsExposedForm', $form_state); - $errors = $form_state->getErrors(); - - // If the exposed form had errors, do not build the view. - if (!empty($errors)) { - $this->view->build_info['abort'] = TRUE; - } if (!$this->view->display_handler->displaysExposed() || (!$block && $this->view->display_handler->getOption('exposed_block'))) { return array(); diff --git a/core/modules/views/src/Tests/Plugin/ExposedFormTest.php b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php index 8a07af8649fcec04557e9cfadf2cb1830dceb237..6c569d98540e2135120be7dd240fa204109c5ab0 100644 --- a/core/modules/views/src/Tests/Plugin/ExposedFormTest.php +++ b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php @@ -36,8 +36,6 @@ class ExposedFormTest extends ViewTestBase { protected function setUp() { parent::setUp(); - $this->enableViewsTestModule(); - $this->drupalCreateContentType(array('type' => 'article')); // Create some random nodes. @@ -400,23 +398,4 @@ protected function getExpectedExposedFormId(ViewExecutable $view) { return Html::cleanCssIdentifier('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() { - $this->drupalGet('views_test_data_error_form_page'); - $this->assertResponse(200); - $form = $this->cssSelect('form.views-exposed-form'); - $this->assertTrue($form, 'The exposed form element was found.'); - $this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered before submitting the normal form.'); - $this->assertRaw('
', 'Views result shown.'); - - $this->drupalPostForm(NULL, array(), t('Submit')); - $this->assertResponse(200); - $form = $this->cssSelect('form.views-exposed-form'); - $this->assertTrue($form, 'The exposed form element was found.'); - $this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered after submitting the normal form.'); - $this->assertRaw('
', 'Views result shown.'); - } - } diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index 991f6c3d887b9e0a6188f73c57721a61c30e8cb8..786b10f642374d08945575292d9df7450fecc37c 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -5,6 +5,7 @@ use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Tags; use Drupal\Core\DependencyInjection\DependencySerializationTrait; +use Drupal\Core\Form\FormState; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\Session\AccountInterface; use Drupal\views\Plugin\views\display\DisplayRouterInterface; @@ -1222,7 +1223,7 @@ public function build($display_id = NULL) { /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface $exposed_form */ $exposed_form = $this->display_handler->getPlugin('exposed_form'); $this->exposed_widgets = $exposed_form->renderExposedForm(); - if (!empty($this->build_info['abort'])) { + if (FormState::hasAnyErrors() || !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; diff --git a/core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php b/core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php deleted file mode 100644 index 6e7fcf14eaebc842ec5f014bf7dbd3fea11e3a87..0000000000000000000000000000000000000000 --- a/core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php +++ /dev/null @@ -1,27 +0,0 @@ - 'view', - '#name' => 'test_exposed_form_buttons', - ); - $build['error_form'] = \Drupal::formBuilder()->getForm('Drupal\views_test_data\Form\ViewsTestDataErrorForm'); - - return $build; - } - -} diff --git a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php deleted file mode 100644 index 77e578c38d056962f8a9fa2a03eb151d53813c4e..0000000000000000000000000000000000000000 --- a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php +++ /dev/null @@ -1,48 +0,0 @@ - 'textfield', - ); - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Submit'), - ); - - return $form; - } - - /** - * {@inheritdoc} - */ - public function validateForm(array &$form, FormStateInterface $form_state) { - $form_state->setErrorByName('text', t('Form validation error')); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - } - -} diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.routing.yml b/core/modules/views/tests/modules/views_test_data/views_test_data.routing.yml index 1bf63f4098dcbee0c3fd7ffcd80df61f1e359aff..cb0ad6379d693ff066516b2e8cee0603966e10bc 100644 --- a/core/modules/views/tests/modules/views_test_data/views_test_data.routing.yml +++ b/core/modules/views/tests/modules/views_test_data/views_test_data.routing.yml @@ -19,11 +19,3 @@ views_test_data.form_multiple: _controller: '\Drupal\views_test_data\Controller\ViewsTestFormMultipleController::testPage' requirements: _access: 'TRUE' - -views_test_data.error_form_page: - path: '/views_test_data_error_form_page' - defaults: - _title: 'Test Views Form Exposed Errors' - _controller: '\Drupal\views_test_data\Controller\ViewsTestDataController::errorFormPage' - requirements: - _access: 'TRUE'