Problem/Motivation

Let's say we need to select a facet filter value by default. This approach works well with views:

```
function hook_views_pre_build(ViewsExecutable $view) {
$exposed = $view->getExposedInput();
$exposed['field_test']['25'] = 25; // // sets 25 as the default active value
$view->setExposedInput($exposed);
}
```

However, after debugging facets_exposed_filters, I noticed it only considers filters/values passed in the $_GET URL parameter: https://git.drupalcode.org/project/facets/-/blob/3.0.x/modules/facets_ex... . And, of course, this doesn’t work when AJAX is enabled.

Ideally, it should also take into account parameters from $view->getExposedInput()

Comments

dejan0 created an issue. See original summary.

dejan0’s picture

Title: facets_exposed_filters doesn't work well with exposed filters from the view » facets_exposed_filters doesn't work well with exposed filters from the view / AJAX related
dejan0’s picture

Status: Active » Needs review
StatusFileSize
new938 bytes

I also noticed that everything in $_GET is also available in $view->getExposedInput(), at least in my cases. Could we simply replace $_GET with $view->getExposedInput()?

Please find an attached patch.

  • strykaizer committed 5344dcd1 on 3.0.x
    Issue #3487510 by dejan0: facets_exposed_filters doesn't work well with...
strykaizer’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.