Description
Currently, when using AssociationField::autocomplete(), it's not possible to use the group_by and choice_label form type options that are available in Symfony's standard EntityType.
This limits the UX possibilities when dealing with large datasets that would benefit from visual grouping in the autocomplete dropdown.
Use Case
I have an entity Issue that belongs to a RedmineProject. When selecting issues in a form, I would like to:
- Group issues by their parent project using
group_by
- Customize the label using
choice_label to avoid redundancy (since the project name is already visible in the group header)
Example of what I'm trying to achieve:
$issues = AssociationField::new('issues', 'issues')
->setFormTypeOption('group_by', fn (Issue $issue) => $issue->getProject()?->getName() ?? 'No project')
->setFormTypeOption('choice_label', fn (Issue $issue) => "[{$issue->getId()}] {$issue->getName()}")
->autocomplete();
Current Behavior
When using autocomplete(), the following error is thrown:
An error has occurred resolving the options of the form "EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudAutocompleteType":
The options "choice_label", "group_by" do not exist.
Expected Behavior
The CrudAutocompleteType should support group_by and choice_label options, similar to Symfony's EntityType, allowing developers to:
- Group autocomplete results visually
- Customize how each option is displayed
Description
Currently, when using
AssociationField::autocomplete(), it's not possible to use thegroup_byandchoice_labelform type options that are available in Symfony's standardEntityType.This limits the UX possibilities when dealing with large datasets that would benefit from visual grouping in the autocomplete dropdown.
Use Case
I have an entity
Issuethat belongs to aRedmineProject. When selecting issues in a form, I would like to:group_bychoice_labelto avoid redundancy (since the project name is already visible in the group header)Example of what I'm trying to achieve:
Current Behavior
When using
autocomplete(), the following error is thrown:Expected Behavior
The
CrudAutocompleteTypeshould supportgroup_byandchoice_labeloptions, similar to Symfony'sEntityType, allowing developers to: