Add support for taxonomy filter in views with hierarchy enabled

Created on 29 October 2023, 8 months ago

Problem/Motivation

When attempting to utilize this module for the purpose of adding a specific class to the options in the selector within the view filter, I encountered an issue. The problem arises when the term hierarchy option is enabled, resulting in a list of options that comprise objects. These objects, in turn, contain a nested array with the option's ID.
Unfortunately, the form_options_attributes_preprocess_form_options_attributes__select__options_attributes hook does not handle this scenario.

Steps to reproduce

Try to add a taxonomy filter to the view, select the dropdown option, and use the hook to add the options_attributes form element. This won't work.

Proposed resolution

To address this, I propose the addition of an extra condition to verify if an option is an object when iterating over an array of options. In such a case, we can extract the ID from the object and utilize it as a key.

✨ Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine taraskorpach Lutsk

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

Comments & Activities

  • Issue created by @taraskorpach
  • @taraskorpach opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review 8 months ago
  • πŸ‡ΊπŸ‡¦Ukraine taraskorpach Lutsk

    I've created a PR. Btw, I'm attaching a patch with PR changes for my own projects. I hope for someone's review.

Production build 0.69.0 2024