summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2017-02-11 21:29:04 -0600
committerxjm2017-02-11 21:29:04 -0600
commit21ba4784ee80c04668444ab9def49dd43b719d53 (patch)
tree77abb44ba2cbc93531df71e26be5f8468dc394c0
parent664a20c1d08dfe3273501fbb2c0e7f70db6cfb50 (diff)
Revert "Issue #1863020 by dawehner, catch, paulmckibben, sunset_bill, damiankloip, alansaviolobo, amarnus, CurtisTAG, deveshpal9, rpayanm, jlbellido: View's build fails when an unrelated form on the same page has validation errors"
This reverts commit 4fc3756debbcab70837ac9f006dec20133bfb5e9.
-rw-r--r--core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php6
-rw-r--r--core/modules/views/src/Tests/Plugin/ExposedFormTest.php21
-rw-r--r--core/modules/views/src/ViewExecutable.php3
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php27
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php48
-rw-r--r--core/modules/views/tests/modules/views_test_data/views_test_data.routing.yml8
6 files changed, 2 insertions, 111 deletions
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 16e2cd1..9272d12 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 @@ abstract class ExposedFormPluginBase extends PluginBase implements CacheableDepe
}
$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 8a07af8..6c569d9 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 @@ class ExposedFormTest extends ViewTestBase {
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('<div class="views-row">', '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('<div class="views-row">', 'Views result shown.');
- }
-
}
diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php
index 991f6c3..786b10f 100644
--- a/core/modules/views/src/ViewExecutable.php
+++ b/core/modules/views/src/ViewExecutable.php
@@ -5,6 +5,7 @@ namespace Drupal\views;
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 @@ class ViewExecutable implements \Serializable {
/** @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 6e7fcf1..0000000
--- a/core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-namespace Drupal\views_test_data\Controller;
-
-/**
- * Controller class for views_test_data callbacks.
- */
-class ViewsTestDataController {
-
- /**
- * Renders an error form page.
- *
- * This contains a form that will contain an error and an embedded view with
- * an exposed form.
- */
- public function errorFormPage() {
- $build = array();
- $build['view'] = array(
- '#type' => '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 77e578c..0000000
--- a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-namespace Drupal\views_test_data\Form;
-
-use Drupal\Core\Form\FormInterface;
-use Drupal\Core\Form\FormStateInterface;
-
-/**
- * Implements a test form that has a validation error.
- */
-class ViewsTestDataErrorForm implements FormInterface {
-
- /**
- * {@inheritdoc}
- */
- public function getFormId() {
- return 'views_test_data_error_form';
- }
-
- /**
- * {@inheritdoc}
- */
- public function buildForm(array $form, FormStateInterface $form_state) {
- $form['text'] = array(
- '#type' => '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 1bf63f4..cb0ad63 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'