Problem/Motivation
As a sitebuilder, i want to use views grouping to have optgroups in the entityreference selection widget.
(Currently, entities are always grouped by bundle, not confiogurable.)
Proposed resolution
Add "group by field" option to views handler and use it in \Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection::stripAdminAndAnchorTagsFromResults.
Remaining tasks
Update branch
Add test coverage
Code review
User interface changes
New option in views handler.
API changes
Probably none.
Data model changes
Probably none.
Release notes snippet
Views grouping is now available for the entityreference views selection handler.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 3193844-12.patch | 7.14 KB | nginex |
Issue fork drupal-3193844
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
Comment #3
geek-merlinUnfortunately the API won't let us do this gracefully, so i bent the bundle key to encode groupings. This works but i wish there'd be a better way.
Manually testes that 1 level of grouping works as expected. Having more grouping levels seems to cough,, but we can simply limit to one level here.
Comment #4
geek-merlinIgnore this patch, only needed for comoser-patches.
Comment #9
matthijsI updated the patch to fix some issues regarding double encoded entities and unwanted line breaks (if you have twig debugging turned on).
Comment #11
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
This will need test coverage. When the tests are added the branch should be updated for 10.1 please
Comment #12
nginex commentedReroll for 9.5.x (also appliable for 10.1.x)
Comment #14
scotwith1tNo time to really evaluate more deeply, but a quick update that this doesn't seem to work as of Drupal 10.1.6.
Comment #17
matthijsCreated a MR for 11.x, which also works for 10.4
Comment #20
smustgrave commentedMoving to NW for the test coverage
Comment #21
r_h-l commentedThis is an excellent and long overdue feature. Only thing I noticed is that in testing, the autocomplete widget seems to strip out the grouping. Any workaround?