Problem/Motivation

In a core Drupal entity reference field when target is a taxonomy, the widget "select" in the form displays the hierarchy of the terms to be selected, while when the same field type is defined as a sub-field in Custom Field, the widget "select" in the form displays all taxonomy terms flattened at the same level.

Steps to reproduce

Create a custom field with a sub field as an entity reference to a taxonomy.
In "Managed Form Display", widget Flexbox, set the widget as "select"
Create a core Entity Reference field to the same taxonomy (without using Custom Field).
Compare how the two fields are presented when editing the entity.

Proposed resolution

It would be fine to have the same behavior of the widget (or an option to display a flattened list ora a hierarchical list)

Remaining tasks

User interface changes

Yes

API changes

n/a

Data model changes

n/a

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.

mario.awad’s picture

An issue that might be related and that can hopefully be resolved at the same time is that the terms are always sorted alphabetically instead of by the weight that is set in the taxonomy terms listing when you reorder them.

apmsooner made their first commit to this issue’s fork.

apmsooner’s picture

Version: 4.0.3 » 4.0.x-dev
Status: Active » Needs review

This turned out to be a simple fix by just letting the selection handler do its job. It wasn't because it was being ignored due to the limit passed in. So, don't do anything dumb like using a select|radios when you have 1000's of references and this should just work now. I also removed the extra level sanitization on the labels for radios widget as the handler already does that so ampersands in titles will no longer get double escaped. The order by weight in Taxonomy vocabulary is indeed now also acknowledged. Please test patch and report back.

svendecabooter’s picture

Status: Needs review » Reviewed & tested by the community

Tested this MR and seems to work as advertised.

apmsooner’s picture

Status: Reviewed & tested by the community » Fixed

Thanks Sven!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.