Symfony-ux inspired events for autocomplete #7048
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello !
I am making this PR because I need to be able to customize autocomplete fields in my project to improve performance and fine tune some specific features of my website.
In symfony-ux autocomplete, it is very easy thanks to a couple of events dispatched right before and right after the autocomplete fields have been created : https://symfony.com/bundles/ux-autocomplete/current/index.html#extending-tom-select.
So I took inspiration from this part of symfony-ux autocomplete's code:
https://github.com/symfony/ux-autocomplete/blob/2.x/assets/src/controller.ts
I am aware that someone has suggested to use symfony-ux in easyadmin :
#6967
But for the time being (whether ea moves to symfony-ux or not) is it possible to dispatch these events every time an Autocomplete object is created by EasyAdmin's frontend ?
This would simplify greatly the process of customizing autocomplete fields in easyadmin !
Instead of manually grabbing the select element by its id and finding tomselect in that select, it would become as simple as