diff --git a/core/modules/views/src/Form/ViewsExposedForm.php b/core/modules/views/src/Form/ViewsExposedForm.php index 04f854d..32d19bd 100644 --- a/core/modules/views/src/Form/ViewsExposedForm.php +++ b/core/modules/views/src/Form/ViewsExposedForm.php @@ -11,6 +11,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Url; use Drupal\views\ExposedFormCache; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -115,7 +116,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#id' => drupal_html_id('edit-submit-' . $view->storage->id()), ); - $form['#action'] = $view->getUrl()->toString(); + $form['#action'] = $view->hasUrl() ? $view->getUrl()->toString() : Url::fromRoute(''); $form['#theme'] = $view->buildThemeFunctions('views_exposed_form'); $form['#id'] = Html::cleanCssIdentifier('views_exposed_form-' . String::checkPlain($view->storage->id()) . '-' . String::checkPlain($display['id'])); diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index 844afc1..d7ae30d 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -1704,6 +1704,19 @@ public function buildTitle() { $this->_buildArguments(); } + public function hasUrl($args = NULL, $display_id = NULL) { + if (!empty($this->override_url)) { + return TRUE; + } + + $display_handler = $this->displayHandlers->get($display_id ?: $this->current_display)->getRoutedDisplay(); + if (!$display_handler instanceof DisplayRouterInterface) { + return FALSE; + } + + return TRUE; + } + /** * Get the URL for the current view. * @@ -1725,12 +1738,9 @@ public function getUrl($args = NULL, $display_id = NULL) { $path = $this->getPath(); } - $display_handler = $this->displayHandlers->get($display_id ?: $this->current_display); + $display_handler = $this->displayHandlers->get($display_id ?: $this->current_display)->getRoutedDisplay(); if (!$display_handler instanceof DisplayRouterInterface) { - $display_handler = $display_handler->getRoutedDisplay(); - if (!$display_handler instanceof DisplayRouterInterface) { - throw new \InvalidArgumentException('You cannot create a URL to a display without routes.'); - } + throw new \InvalidArgumentException('You cannot create a URL to a display without routes.'); } if (!isset($args)) {