Address undefined index warning when a custom views field supports being "Exposed"

Created on 18 April 2023, over 1 year ago
Updated 5 June 2024, 3 months ago

Problem/Motivation

When a custom view filter plugin implements the canExpose() and isExposed() methods.

The following warning is emitted:

Warning: Undefined array key 1 in better_exposed_filters_preprocess_views_exposed_form() (line 69 of modules/contrib/better_exposed_filters/includes/better_exposed_filters.theme.inc).
better_exposed_filters_preprocess_views_exposed_form(Array, 'views_exposed_form', Array)

This is because the field name follows the convention of field-field_machine_name rather than the expected filter-filter_machine_name.

We'd need slightly better index checking.

Steps to reproduce

Add an exposed Drupal views field plugin with a form to a view with better exposed filters active.

Proposed resolution

Add better index checking.

Or expand better_exposed_filters to support all handlers, since the ability to expose handlers is declared in \Drupal\views\Plugin\views\HandlerBase::canExpose() and \Drupal\views\Plugin\views\HandlerBase::isExposed()

Remaining tasks

Provide issue fork/patch.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

πŸ› Bug report
Status

Fixed

Version

6.0

Component

Code

Created by

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

Production build 0.71.5 2024