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

Created on 5 January 2024, 6 months ago
Updated 18 June 2024, 12 days 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

Postponed: needs info

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 about 1 month 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 about 1 month ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thanks for testing

  • Status changed to Postponed: needs info 12 days 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

Production build 0.69.0 2024