Views exposed filters don't combine with contextual filters when using exposed form in block

Created on 25 October 2016, about 8 years ago
Updated 5 September 2024, 4 months ago

Problem/Motivation

View exposed filters and contextual filters cannot be used together. The contextual filter is ignored when the exposed filters are used.

Steps to reproduce

Create a View with both exposed filters and contextual filters. Try to use the exposed filters.

Proposed resolution

Pass the existing contextual filter arguments to the View when exposed filters are used.

Remaining tasks

Finalize implementation.

User interface changes

None except that the filters will work as expected.

API changes

None.

Data model changes

None.

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated 5 minutes ago

Created by

πŸ‡§πŸ‡ͺBelgium screon

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • πŸ‡ͺπŸ‡ΈSpain javitan

    #59 solves the issue for me using Drupal 9.5.5. I'm using a view with a contextual filter and I'm exposing the filters with Better Exposed Filters. Also the Media Library is working normally. Anyway, I removed an empty if.

  • last update over 1 year ago
    30,283 pass, 50 fail
  • πŸ‡ͺπŸ‡ΈSpain javitan

    Ups, my fault. I fixed my last change.

  • last update over 1 year ago
    30,341 pass
  • Status changed to Needs review 10 months ago
  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    Re-roll of #64 for 11.x.

  • Status changed to Needs work 10 months ago
  • The Needs Review Queue Bot β†’ tested this issue.

    While you are making the above changes, we recommend that you convert this patch to a merge request β†’ . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

  • Pipeline finished with Success
    10 months ago
    Total: 593s
    #123393
  • Status changed to Needs review 10 months ago
  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦
  • Status changed to Needs work 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    There's no issue summary. Please use the standard issue template.

  • Status changed to Needs review 10 months ago
  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    Problem/Motivation

    View exposed filters and contextual filters cannot be used together. The contextual filter is ignored when the exposed filters are used.

    Steps to reproduce

    Create a View with both exposed filters and contextual filters. Try to use the exposed filters.

    Proposed resolution

    Pass the existing contextual filter arguments to the View when exposed filters are used.

    Remaining tasks

    Finalize implementation.

    User interface changes

    None except that the filters will work as expected.

    API changes

    None.

    Data model changes

    None.

    Release notes snippet

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦
  • Status changed to Needs work 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Left some comments on MR.

    Will need some test coverage to show the issue.

    Hiding patches for clarity.

  • Pipeline finished with Failed
    9 months ago
    Total: 178s
    #128666
  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    Thanks; changes in comments committed

  • Pipeline finished with Failed
    9 months ago
    Total: 191s
    #128679
  • πŸ‡ΊπŸ‡¦Ukraine rollins

    I tested the code from MR and got the next error:
    Fatal error: Type of Drupal\views\Form\ViewsExposedForm::$routeMatch must not be defined (as in class Drupal\Core\Form\FormBase) in /var/www/html/web/core/modules/views/src/Form/ViewsExposedForm.php on line 21

  • Status changed to Needs review 8 months ago
  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    I have removed using of constructor property promotion which should resolve the $routeMatch error.

  • Pipeline finished with Success
    8 months ago
    Total: 679s
    #166456
  • Status changed to Needs work 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thanks for keeping this going

    Was previously tagged for tests so moving back to NW for that.

    Left a comment about using promotion that should simplify things.

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    I removed the constructor property promotion because when it is used, the property has a type declared. That type doesn't match the parent and so you get the error shown in #74.

    To avoid all this, I just updated the merge request to use ::getRouteMatch().

  • Pipeline finished with Success
    8 months ago
    Total: 603s
    #168804
  • Status changed to RTBC 4 months ago
  • πŸ‡¬πŸ‡·Greece vensires

    The changes from the latest MR solved the problem for me. Thank you!
    Setting it as RTBC.

  • Status changed to Needs work 4 months ago
  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

    This still needs automated test coverage before it can be committed.

  • Pipeline finished with Failed
    4 months ago
    Total: 132s
    #274664
  • πŸ‡¬πŸ‡·Greece vensires

    In my latest change I allowed the inclusion of parameters with the all value.
    Without this change, URLs like /foo/bar/[arg_0]/[arg_1]/[arg_2] throw an exception if [arg_2] has a value but [arg_1] is all.

  • Pipeline finished with Failed
    4 months ago
    Total: 805s
    #274701
Production build 0.71.5 2024