Warning: Undefined array key "#name"

Created on 6 June 2025, about 1 month ago

Problem/Motivation

When using the Better Exposed Filters (BEF) module in conjunction with Facets, and enabling the "Hides the label visually, so it is still usable for accessibility purposes" option for an Content type Facet link widget exposed filter, a Warning: Undefined array key "#name" is thrown in better_exposed_filters_theme_suggestions_alter().

This occurs when the element in question (which is likely a visually hidden label or a similar non-form-input element generated by BEF's accessibility feature) does not possess a #name property. This can clutter logs and might hint at a need for more robust handling of diverse render array structures within the function.

Steps to reproduce

  1. Ensure you have Drupal 10.x (e.g., 10.4) installed.
  2. Install and enable the following modules:
    • Views (core)
    • Search API
    • Facets (3.x)
    • Better Exposed Filters (7.0.5)
  3. Configure a Search API index (e.g., for content, users, etc.).
  4. Create at least one Facet (e.g., for 'Content type' or any field that generates a meaningful facet) and associate it with your Search API index.
  5. Create a new View that displays results from your Search API index.
  6. Add an exposed filter to your View (e.g., "Content type").
  7. Under "Exposed form style," set it to "Better Exposed Filters" and click "Settings."
  8. Within the Better Exposed Filters settings:
    • Enable the checkbox for "Hides the label visually, so it is still usable for accessibility purposes." under the facet advanced settings
  9. Save the View.
  10. Navigate to the View's page in the browser (e.g., /search if your page path is /search) without any search terms or filters applied yet.

Expected behavior: The page loads without any PHP warnings.

Actual behavior: A PHP warning is displayed/logged:

Warning: Undefined array key "#name" in better_exposed_filters_theme_suggestions_alter() (line 45 of modules/contrib/better_exposed_filters/includes/better_exposed_filters.theme.inc).

Full stack trace from my system:

Warning: Undefined array key "#name" in better_exposed_filters_theme_suggestions_alter() (line 45 of modules/contrib/better_exposed_filters/includes/better_exposed_filters.theme.inc).
better_exposed_filters_theme_suggestions_alter() (Line: 552)
Drupal\Core\Extension\ModuleHandler->alter() (Line: 393)
Drupal\Core\Theme\ThemeManager->buildThemeHookSuggestions() (Line: 220)
Drupal\Core\Theme\ThemeManager->render() (Line: 518)
Drupal\Core\Render\Renderer->doRender() (Line: 531)
Drupal\Core\Render\Renderer->doRender() (Line: 257)
Drupal\Core\Render\Renderer->render() (Line: 484)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 53)
__TwigTemplate_b4ef0b5b4b4baa73de60beb56c58b1b8->doDisplay() (Line: 388)
Twig\Template->yield() (Line: 344)
Twig\Template->display() (Line: 359)
Twig\Template->render() (Line: 51)
Twig\TemplateWrapper->render() (Line: 33)
twig_render_template() (Line: 348)
Drupal\Core\Theme\ThemeManager->render() (Line: 518)
Drupal\Core\Render\Renderer->doRender() (Line: 257)
Drupal\Core\Render\Renderer->render() (Line: 484)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 70)
__TwigTemplate_e3d1a27888ad4fc2a24d6bf88294e100->doDisplay() (Line: 388)
Twig\Template->yield() (Line: 344)
Twig\Template->display() (Line: 359)
Twig\Template->render() (Line: 51)
Twig\TemplateWrapper->render() (Line: 33)
twig_render_template() (Line: 348)
Drupal\Core\Theme\ThemeManager->render() (Line: 518)
Drupal\Core\Render\Renderer->doRender() (Line: 531)
Drupal\Core\Render\Renderer->doRender() (Line: 257)
Drupal\Core\Render\Renderer->render() (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 669)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 53)
Asm89\Stack\Cors->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)
πŸ› Bug report
Status

Active

Version

7.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain eduardo morales alberti Spain, πŸ‡ͺπŸ‡Ί

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024