function HandlerBase::showExposeForm

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::showExposeForm()
  2. 8.9.x core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::showExposeForm()
  3. 11.x core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::showExposeForm()

Shortcut to display the exposed options form.

Parameters

array $form: An alterable, associative array containing the structure of the form, passed by reference.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ViewsHandlerInterface::showExposeForm

2 calls to HandlerBase::showExposeForm()
FilterPluginBase::buildOptionsForm in core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
Provide the basic form which calls through to subforms.
SortPluginBase::buildOptionsForm in core/modules/views/src/Plugin/views/sort/SortPluginBase.php
Basic options for all sort criteria.

File

core/modules/views/src/Plugin/views/HandlerBase.php, line 531

Class

HandlerBase
Base class for Views handler plugins.

Namespace

Drupal\views\Plugin\views

Code

public function showExposeForm(&$form, FormStateInterface $form_state) {
  if (empty($this->options['exposed'])) {
    return;
  }
  $this->buildExposeForm($form, $form_state);
  // When we click the expose button, we add new gadgets to the form but they
  // have no data in POST so their defaults get wiped out. This prevents
  // these defaults from getting wiped out. This setting will only be TRUE
  // during a 2nd pass rerender.
  if ($form_state->get('force_expose_options')) {
    foreach (Element::children($form['expose']) as $id) {
      if (isset($form['expose'][$id]['#default_value']) && !isset($form['expose'][$id]['#value'])) {
        $form['expose'][$id]['#value'] = $form['expose'][$id]['#default_value'];
      }
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.