Error on view after adding a Facet Exposed Filter

Created on 17 December 2024, 4 months ago

When adding a facet exposed filter to a view, and trying the view the page in the front end I get the following error:

The website encountered an unexpected error. Try again later.

TypeError: Cannot access offset of type string on string in Drupal\facets\Entity\Facet->getWidgetInstance() (line 396 of modules/contrib/facets/src/Entity/Facet.php).
Drupal\facets_range_widget\Plugin\facets\processor\SliderProcessor->postQuery(Object) (Line: 144)
Drupal\facets_exposed_filters\Plugin\views\filter\FacetsFilter->valueForm(Array, Object) (Line: 969)
Drupal\views\Plugin\views\filter\FilterPluginBase->buildExposedForm(Array, Object) (Line: 123)
Drupal\views\Form\ViewsExposedForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('views_exposed_form', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm('\Drupal\views\Form\ViewsExposedForm', Object) (Line: 134)
Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase->renderExposedForm() (Line: 115)
facets_exposed_filters_views_post_execute(Object)
call_user_func_array(Object, Array) (Line: 409)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'facets_exposed_filters') (Line: 388)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('views_post_execute', Object) (Line: 408)
Drupal\Core\Extension\ModuleHandler->invokeAll('views_post_execute', Array) (Line: 1451)
Drupal\views\ViewExecutable->execute(NULL) (Line: 1470)
Drupal\views\ViewExecutable->render() (Line: 199)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1646)
Drupal\views\ViewExecutable->executeDisplay('results_page', Array) (Line: 81)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 859)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 421)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 53)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom c_archer Cumbria

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

Comments & Activities

  • Issue created by @c_archer
  • πŸ‡ΊπŸ‡ΈUnited States mengi

    How did you setup the facet filters? I can use a simple facet exposed filters with no errors.

  • πŸ‡¬πŸ‡§United Kingdom c_archer Cumbria

    I added a date range facet and a commerce price field with a range facet.

  • πŸ‡¨πŸ‡ΏCzech Republic radimsulak

    I am getting the same error when I add a range slider for a numeric field.

  • πŸ‡ΊπŸ‡ΈUnited States mengi

    From #search slack about sliders;

    The slider widget hasnt been tested/implemented yet in facets exposed filters setup.
    We prefer using either min/max value filter, or hardcoded range-values as tags, as it works better on mobile.
    Not sure if BEF has a slider support. That might be a quickfix, if BEF already has a slider, to not use facets for it but a regular filter instead

    Sliders don't work with 3.x+facets exposed filters yet. It was suggested to use regular exposed filters, with a con being that the filter does not adjust their values depending on the results.

  • πŸ‡¬πŸ‡§United Kingdom intrafusion Edinburgh, UK

    I get exactly the same error, different line number, when I simply add a facet to the filter criteria. Same error is also generated when I click on settings.

    This might be a D11 issue as we've upgraded recently

  • πŸ‡¬πŸ‡§United Kingdom intrafusion Edinburgh, UK

    Further debugging has discovered a difference between Facets v3 & Better Exposed Filters v7 (required for D11)

    After amending 'widget' => '<nowidget>', to 'widget' => ['type' => 'dropdown', 'config' => []], in \Drupal\facets_exposed_filters\Plugin\views\filter\FacetsFilter::getFacet the error is now gone and I can access the settings link against the filter, but it's not possible to change widgets as per https://project.pages.drupalcode.org/facets/exposed_filters/#better-expo...

Production build 0.71.5 2024