Is it possible to use a property of the associated Entity as the choice label, rather than the associated Entity ID when using the autocomplete method on an AssociationField in an EasyAdmin EntityCrudController?
Example:
I have 3 Entities with the following properties:
User
name
Certification
name
UserCertification
User
Certification
I have the following in my UserCertificationCrudController:
public function configureFields(string $pageName): iterable
{
return [
AssociationField::new('user')
->autocomplete(),
AssociationField::new('memberCertification')
->autocomplete(),
'lastRenewed',
'expiration',
];
}
See the following screenshot when creating a new UserCertification
:
The autocomplete value is a reference to the respective Entity ID. How would we replace User#
with the name property on the user?
Things I have already tried with no success:
- using a ChoiceField and supplying the 'class' and 'choice_label' to the
ChoiceField->setFormTypeOptions()
method, as well as the result ofUserRepository->FindAll()
to theChoiceField->setChoices()
method - supplying the 'class' and 'choice_label' to the
AssociationField->setFormTypeOptions()
method