"Rewrite the text displayed" doesn't respect hierarchical select list

Created on 5 January 2024, 11 months ago
Updated 5 July 2024, 5 months ago

Problem/Motivation

"Rewrite the text displayed" doesn't respect hierarchical select lists such as "Permission" filter

Steps to reproduce

Change the "-Any-" value to "Select..." for hierarchical select list via BEF and go back to preview
You can see the bug in changed select list and error:

Warning: Array to string conversion in Drupal\better_exposed_filters\BetterExposedFiltersHelper::rewriteOptions() (line 86 of modules/contrib/better_exposed_filters/src/BetterExposedFiltersHelper.php).
Drupal\better_exposed_filters\BetterExposedFiltersHelper::rewriteOptions(Array, '- Any -|Select', 1) (Line: 191)

Proposed resolution

Condition at rows 85-87 in BetterExposedFiltersHelper.php breaks arrays in hierarchy
Need to write specific condition for such list

πŸ› Bug report
Status

Closed: outdated

Version

7.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine luckie joe

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

Comments & Activities

  • Issue created by @luckie joe
  • πŸ‡¨πŸ‡¦Canada pub497

    I have a quick patch here for it to work with the special 'All' scenario, it just replaces that object with its string so the rewrite works. For this rewrite feature to work with other hierarchical lists e.g. in my case it was ones that contains option groups ( like filtering by workflow moderation states for example) would need some more work, I am just using a form_alter hook to manually edit those

  • Status changed to Postponed: needs info 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    There was a fix or two that went into. Can you replicate on the latest 6.0.x?

  • πŸ‡¨πŸ‡¦Canada pub497

    @smustgrave issue seems to still exist (on 6.0.6)
    e.g. with moderation states & switching '- Any -' to 'All'

  • Status changed to Needs work 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thanks for testing

  • Status changed to Postponed: needs info 5 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    I do believe this has been fixed. Following the steps

    I checked "Rewrite the text displayed based on key"
    And added All|Select... to the replacement

    Worked as expected nothing in the logs

  • Status changed to Closed: outdated 5 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    If still an issue in 7.0.x please reopen.

Production build 0.71.5 2024