You are here

function ExposedFormPluginBase::render_exposed_form in Views (for Drupal 7) 8.3

Render the exposed filter form.

This actually does more than that; because it's using FAPI, the form will also assign data to the appropriate handlers for use in building the query.

File

lib/Drupal/views/Plugin/views/exposed_form/ExposedFormPluginBase.php, line 138
Definition of Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase.

Class

ExposedFormPluginBase
The base plugin to handle exposed filter forms.

Namespace

Drupal\views\Plugin\views\exposed_form

Code

function render_exposed_form($block = FALSE) {

  // Deal with any exposed filters we may have, before building.
  $form_state = array(
    'view' => &$this->view,
    'display' => &$this->display,
    'method' => 'get',
    'rerender' => TRUE,
    'no_redirect' => TRUE,
    'always_process' => TRUE,
  );

  // Some types of displays (eg. attachments) may wish to use the exposed
  // filters of their parent displays instead of showing an additional
  // exposed filter form for the attachment as well as that for the parent.
  if (!$this->view->display_handler
    ->displaysExposed() || !$block && $this->view->display_handler
    ->getOption('exposed_block')) {
    unset($form_state['rerender']);
  }
  if (!empty($this->ajax)) {
    $form_state['ajax'] = TRUE;
  }
  $form_state['exposed_form_plugin'] = $this;
  $form = drupal_build_form('views_exposed_form', $form_state);
  $output = drupal_render($form);
  if (!$this->view->display_handler
    ->displaysExposed() || !$block && $this->view->display_handler
    ->getOption('exposed_block')) {
    return "";
  }
  else {
    return $output;
  }
}