function Block::elementPreRender

Exposed widgets.

Exposed widgets typically only work with ajax in Drupal core, however #2605218 totally breaks the rest of the functionality in this display and in Core's Block display as well, so we allow non-ajax block views to use exposed filters and manually set the #action to the current request uri.

Overrides DisplayPluginBase::elementPreRender

File

modules/ctools_views/src/Plugin/Display/Block.php, line 440

Class

Block
Provides a Block display plugin.

Namespace

Drupal\ctools_views\Plugin\Display

Code

public function elementPreRender(array $element) {
  /** @var \Drupal\views\ViewExecutable $view */
  $view = $element['#view'];
  if (!empty($view->exposed_widgets['#action']) && !$view->ajaxEnabled()) {
    $view->exposed_widgets['#action'] = $this->request
      ->getRequestUri();
  }
  return parent::elementPreRender($element);
}