Update to work with Facets 3.0 facets_exposed_filters

Created on 31 January 2025, 2 months ago

Problem/Motivation

The submodule facets_exposed_filters in Facets 3 changed how facets are attached to views. Facets are now exposed facet filter fields, not blocks using a facet source. When I updated a project from facets@3.0beta1 to facets 3.0 I received the following error for the view with a relative date facet configured.

Error: Call to a member function getRawValue() on array in Drupal\relative_date_facets\Plugin\facets\query_type\SearchApiRelativeDate->build() (line 119 of /app/web/modules/contrib/relative_date_facets/src/Plugin/facets/query_type/SearchApiRelativeDate.php).

Here's a patch that I recently created for a project that I updated from facets@3.0beta1 to facets 3.0. It works for my simple implementation of exposing a relative date filter with 3 options. It needs some work on the Ajax for the config form to get it to dynamically add new relative date field sets using the "Add more" functionality. I spent some time trying to figure it out, but there's a core bug in views forms that use Ajax where the incorrect config form gets passed, so it's not a straightforward task to fix.

Here's a link to the views ajax issue: https://www.drupal.org/project/drupal/issues/3447838 πŸ› Ajax callback inside views plugin doesn't work. Active

I ended up just adding a new number field to the form to store the number of relative date range options needed. You just set the count then save and reopen the form and that number of field sets are available.

I intend to create a MR for this issue, but I've not had the time to do so.

πŸ› Bug report
Status

Active

Version

1.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States simplyshipley

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

Comments & Activities

Production build 0.71.5 2024