interface ExposedFormPluginInterface

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginInterface.php \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface
  2. 10 core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginInterface.php \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface
  3. 8.9.x core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginInterface.php \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface

Interface for exposed filter form plugins.

Exposed form plugins handle the rendering, validation, and submission of exposed forms, and may add additional form elements. These plugins can also alter the view query. See \Drupal\views\Plugin\views\exposed_form\InputRequired as an example of that functionality.

Hierarchy

Expanded class hierarchy of ExposedFormPluginInterface

All classes that implement ExposedFormPluginInterface

See also

\Drupal\views\Annotation\ViewsExposedForm

\Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase

Related topics

1 file declares its use of ExposedFormPluginInterface
DisplayKernelTest.php in core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php

File

core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginInterface.php, line 42

Namespace

Drupal\views\Plugin\views\exposed_form
View source
interface ExposedFormPluginInterface extends ViewsPluginInterface {
  
  /**
   * Renders the exposed form.
   *
   * This method iterates over each handler configured to expose widgets
   * to the end user and attach those widgets to the exposed form.
   *
   * @param bool $block
   *   (optional) TRUE if the exposed form is being rendered as part of a
   *   block; FALSE (default) if not.
   *
   * @return array
   *   Form build array. This method returns an empty array if the form is
   *   being rendered as a block.
   *
   * @see \Drupal\views\ViewExecutable::build()
   */
  public function renderExposedForm($block = FALSE);
  
  /**
   * Runs before the view is rendered.
   *
   * Implement if your exposed form needs to run code before the view is
   * rendered.
   *
   * @param \Drupal\views\ResultRow[] $values
   *   An array of all ResultRow objects returned from the query.
   *
   * @see \Drupal\views\ViewExecutable::render()
   */
  public function preRender($values);
  
  /**
   * Runs after the view has been rendered.
   *
   * Implement if your exposed form needs to run code after the view is
   * rendered.
   *
   * @param string $output
   *   The rendered output of the view display.
   *
   * @see \Drupal\views\ViewExecutable::render()
   */
  public function postRender(&$output);
  
  /**
   * Runs before the view has been executed.
   *
   * Implement if your exposed form needs to run code before query execution.
   *
   * @see \Drupal\views\Plugin\views\display\DisplayPluginBase::preExecute()
   */
  public function preExecute();
  
  /**
   * Runs after the view has been executed.
   *
   * Implement if your exposed form needs to run code after query execution.
   */
  public function postExecute();
  
  /**
   * Alters the exposed form.
   *
   * The exposed form is built by calling the renderExposedForm() method on
   * this class, and then letting each exposed filter and sort handler add
   * widgets to the form. After that is finished, this method is called to
   * let the class alter the finished form.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   *
   * @see \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface::renderExposedForm()
   * @see \Drupal\views\Form\ViewsExposedForm::buildForm()
   */
  public function exposedFormAlter(&$form, FormStateInterface $form_state);
  
  /**
   * Validates the exposed form submission.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   *
   * @see \Drupal\views\Form\ViewsExposedForm::validateForm()
   */
  public function exposedFormValidate(&$form, FormStateInterface $form_state);
  
  /**
   * Submits the exposed form.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   * @param array $exclude
   *   Array of keys that will not appear in $view->exposed_raw_input; for
   *   example, 'form_build_id'.
   *
   * @see \Drupal\views\Form\ViewsExposedForm::submitForm()
   */
  public function exposedFormSubmit(&$form, FormStateInterface $form_state, &$exclude);

}

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