postExecute() is never called on exposed form plugins

Created on 2 March 2016, almost 9 years ago
Updated 15 May 2023, almost 2 years ago

Problem/Motivation

While working on #2642598: Create an interface for the public methods on ExposedFormPluginBase β†’ I noticed the method postExecute() is never called on exposed form plugins.

Proposed resolution

Call this method on \Drupal\views\ViewExecutable::postExecute()

Remaining tasks

An example of the code to execute could be:

    /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface $exposed_form */
    $exposed_form = $this->display_handler->getPlugin('exposed_form');
    $exposed_form->postExecute();

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Active

Version

10.1 ✨

Component
ViewsΒ  β†’

Last updated about 21 hours ago

Created by

πŸ‡¦πŸ‡·Argentina dagmar Argentina

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • There are many situations where developers want to alter View exposed forms based on the results (i.e. after the View is executed).

    For instance:

    • Set the default value of an exposed filter depending on the min/max value found in the result set
    • Removing options from a select list if no results found (i.e. remove tags from an exposed taxonomy term filter)

    +1 to make this issue move forward.

    Assigning it to me, will try to propose a patch asap.

  • Status changed to Closed: works as designed 26 days ago
  • πŸ‡³πŸ‡±Netherlands johnv

    I guess there is a misunderstanding here.

    From 'web\core\modules\views\src\Plugin\views\exposed_form\ExposedFormPluginInterface.php'

    Exposed forms are used for filters, sorts, and pager settings that are
    * exposed to site visitors. Exposed form plugins handle the rendering,
    * validation, and submission of exposed forms, and may add additional form
    * elements.

    So, for example rendering the list box on an exposed filter.

    But it does NOT change the output of the query. For that you need the filter/sort/... handler, that IS called in postExecute().
    Regarding #18, you need to implement hook_views_post_execute() or hook_field_views_pre_render() in your Views filter plugin.
    However, doing that, you will encounter query result problems, as summarized in 🌱 [META] Fix pager bug reports Active .

Production build 0.71.5 2024