Loading
feat: #3268207 Hand the entity being edited to the selection plugin
Issue: https://www.drupal.org/project/autocomplete_deluxe/issues/3268207
Builds on the patches from Robert, Guido and the retests: a selection handler gets the entity being edited, so it can do things like leave the entity out of its own suggestions.
- The widget puts the entity into the element's
#selection_settings, soEntityAutocomplete::validateEntityAutocomplete()sees it too, and sends the entity type and id with the autocomplete request when the entity is saved. - The controller loads the entity into the selection settings only when it loads and the user may view it, and an unknown entity type is caught rather than thrown, so a crafted request cannot 500 the route or smuggle an unviewable entity into a plugin.
- The hashed settings and the key value store keep leaving the entity out, so one field keeps one key in the store whatever entity is being edited.
Tested on a fresh Drupal 11 site built for this issue, with a small selection plugin that excludes the term named like the host entity: on the edit form of a node titled Alpha, typing Al offers Albion and Alps only; on the add form all three terms are offered. A request with an unknown entity type, another user's entity, or a missing id answers 200 and simply skips the entity.
AI-Generated: Yes
Checkpoints:
- File an issue
- Addition/Change/Update/Fix
- Testing to ensure no regression
-
Automated unit testing coverage - Automated functional testing coverage
- UX/UI designer responsibilities
- Readability
- Accessibility
- Performance
- Security
- Developer Documentation
- User Guide Documentation
- Reviewed by human
- Code review by maintainers
- Full testing and approval
- Credit contributors
- Review with the product owner
- Release notes snippet
- Release
Edited by Rajab Natshah