Apologies if this is a duplicate but a search did not reveal anyone else reporting this issue that I could find.
Problem/Motivation
When adding a field referencing Vocabulary configuration entities, the weight of the Vocabularies seems to be ignored on the Entity Reference field widgets.
Example
Given the following configured vocabularies created in the following order and weights set as below:
- X (weight 2)
- Y (weight 3)
- Z (weight 1)
Using the options_buttons field widget with unlimited cardinality would expect to see three checkboxes in the following order, following the weight of the vocabulary:
- Z
- X
- Y
What I actually see is an alphabetical list of the vocabularies, regardless of weight. This list seems to be sorted alphabetically on the vocabulary machine name. If you were to add a new Vocabulary called 'A' it would appear at the top of this list.
- X
- Y
- Z
This is a real issue for me at the moment because we're working on a site with over 100 vocabularies and this order does not follow the order the customer has configured in the CMS which is making it very hard to find specific items, especially once vocabularies names are tweaked to be different from their machine names.
Proposed resolution
I'm not sure, I couldn't find the specific lines of code in the entity reference fields which load in the config entities, however if these cant be sorted/returned by the storage interface then perhaps it needs to be done separately afterwards? I'm pretty sure database entities don't have this problem and a list of Terms would be sorted correctly.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | config-entity-storage-sort-2969183-4.patch | 674 bytes | mattjones86 |
Comments
Comment #2
mattjones86UPDATE: So the default
ConfigEntityListBuilderclass has a load method which sorts the results like so:I would propose to also sort the results in
ConfigEntityStoragein the same way?In fact sorting in the list builder probably isn't required if it's being done at the storage level. Thoughts?
Comment #3
mattjones86Comment #4
mattjones86Whoops some white space got in there.
Comment #5
andypostComment #6
andypostThis is duplicate of #1821274: Add back ability to sort on vocabulary weight and name
Also #3008064: Deprecate vocabulary weight property