Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The taxonomy terms are not sorted following any of the different sort criteria (name, Term ID) or the sort order as set on the edit tab of the field when displayed as checkboxes or as select list.
Instead they are displayed per vocabulary (with the select list displaying the vocabulary name as well) and for each vocabulary sorted by weight.
Proposed resolution
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#3 | 2412553.patch | 927 bytes | amateescu |
Comments
Comment #1
ifrikComment #2
BerdirThis is because the selection plugin is using taxonom_get_tree(), which can only do that. There is no other way to display a term hierarchy.
A quickfix would be to hide the sort option for term references, a more complete fix to make that behavior configurable.
Comment #3
amateescu CreditAttribution: amateescu commentedI think we need to go with the simple fix for 8.0.x and maybe look into adding support for sorting
\Drupal\taxonomy\TermStorageInterface::loadTree()
in 8.1.x.Comment #4
jibranI like #3 but can we let user know about this behavior? Something like, "Terms are only sorted by their weight" as a markup.
Maybe create a followup and add a link here in comments.
Comment #5
amateescu CreditAttribution: amateescu commented@jibran, why do you think that adding that piece of #markup in there will help users? They have no way to act upon it anyway, so IMO it will be just confusing.
Comment #6
jibranI agree it's TMI.
Comment #7
claudiu.cristea@amateescu,
Shouldn't we fill an issue for that? :)
Comment #8
alexpottCan this bug be tested?
Comment #9
amateescu CreditAttribution: amateescu commentedHm.. that's tricky to answer. The current patch just removed the sort option from the UI, so all we can test is that it doesn't show up anymore.
However, if we wanted to take the other route and add sorting capability to
\Drupal\taxonomy\TermStorageInterface::loadTree()
, that should definitely be tested.Comment #10
amateescu CreditAttribution: amateescu commentedGiven that the taxonomy reference field doesn't have any sort either, this is not a regression for #1847596: Remove Taxonomy term reference field in favor of Entity reference, and asserting that a select element is not visible in the UI is not really helpful if we can't pair it with a positive assertion on the same xpath :)
Comment #11
amateescu CreditAttribution: amateescu commentedThis is the pre-existing issue that we can use for adding sorting capability to the taxonomy selection plugin: #2372225: Add sort setting for taxonomy term autocomplete results
Comment #12
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 8dbdbd7 and pushed to 8.0.x. Thanks!
Comment #15
DuaelFrThere is an open discussion about that setting in #2372225-13: Add sort setting for taxonomy term autocomplete results