Problem/Motivation

When SHS module (https://www.drupal.org/project/shs) is installed, this new widget does not appear as a possible widget in custom field subfields.

Steps to reproduce

Create a new field with a subfield that is an entity reference to a taxonomy term.
Install SHS module.
The new SHS widget does not appear as a possible choice for the subfield widget.

Proposed resolution

Support integration with SHS.
Created a custom hierarchical select widget plugin for our module. A simpler yet more functional version of alternative options.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

giuse69 created an issue. See original summary.

apmsooner’s picture

There's also this one: https://www.drupal.org/project/cshs. Need to research the best option to consider.

giuse69’s picture

Yes, but CSHS does not fit for large taxonomies since it loads all the vocabulary terms and send them to the browser, the selection does not involve ajax loading while navigating the hierarchy.

apmsooner’s picture

Version: 3.0.0-rc12 » 3.0.x-dev

I'm not going to integrate with SHS module. I don't particularly like the limitations with a single bundle requirement and I think theres a little too much going on with the approach not to mention the number of unresolved issues is concerning to me. I think I can create a much simpler alternative that serves the same basic need. Stay tuned.

giuse69’s picture

ok

apmsooner’s picture

Status: Active » Needs review

This is first draft if you want to test out the patch. There's a few hardcoded styles just to get something visually appealing that I'll refactor but functionally... I think it's working really well. In the field settings, you'll see the new "Hierarchical select widget" as an option. Just use the default reference method for now as I haven't looked at the views option. There will be a couple extra settings at the bottom of the form:

- Force deepest level
- Show level labels

I think the descriptions are self explanatory. Try it out and let me know how it works for you. It should support multi-lingual and work fine in paragraphs as well.

giuse69’s picture

You're great! It works with a couple of issues:
- language translation of taxonomy terms with Hierarchical formatter seems not to work here (always taxo term in default language is shown) but I think it's a problem of the formatter and not of this thread.
- when used with flexbox formatter (not stacked), the series of selection boxes have a white space below the label that is not present in other subfield (like a select list) so the selection boxes are not aligned.
cheers

Giuse

  • apmsooner committed abeb7326 on 3.0.x
    Issue #3491436 by apmsooner, giuse69: Support SHS widget
    
apmsooner’s picture

Title: Support SHS widget » Support hierarchical select widget
Issue summary: View changes
Status: Needs review » Fixed

The translations are working just fine in the widget as well as the formatter in my testing. The widget now supports views to control the 1st level of hierarchy although in most cases, the default formatter should be sufficient as we're only fetching the terms for each level to help with performance.

apmsooner’s picture

Status: Fixed » Closed (fixed)