Describe the bug
After not being able to find in the docs on how to apply a filter based on a property of the entity I'd like to ask if it's even possible.
To Reproduce
As an example, I have have a many-to-one relation from User to Colour denoted with the property userColour. The Colour entity consists of a property colourCode which is of type string.
In the CRUD controller for User, let's say I have the following fields configured:
return [
AssociationField::new('userColour'),
TextField::new('userColour.colourCode'),
];
Now I can use the EntityFilter on userColour to filter (which works), but if I wanted to filter on userColour.colourCode it doesn't seem to be that easy.
return $filters
->add(EntityFilter::new('userColour')) // works
->add(EntityFilter::new('userColour.colourCode')) // doesn't work
Throwing the following error/stacktrace:
Error:
Call to a member function getAsDto() on array
at vendor/easycorp/easyadmin-bundle/src/Factory/FilterFactory.php:72
at EasyCorp\Bundle\EasyAdminBundle\Factory\FilterFactory->create(object(FilterConfigDto), object(FieldCollection), object(EntityDto))
(vendor/easycorp/easyadmin-bundle/src/Controller/AbstractCrudController.php:124)
at EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController->index(object(AdminContext))
(vendor/symfony/http-kernel/HttpKernel.php:152)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor/symfony/http-kernel/HttpKernel.php:74)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(vendor/symfony/http-kernel/Kernel.php:202)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35)
at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
(vendor/autoload_runtime.php:29)
at require_once('/app/vendor/autoload_runtime.php')
(public/index.php:5)
So am I missing something obvious here, either wrongly passing the property name or missing some options? Or is this either something that isn't working correctly, or maybe should a custom filter be used for such cases?
Additional context
Versions:
- EA:
4.0.2
- SF:
6.0.1
- PHP:
8.1
Describe the bug
After not being able to find in the docs on how to apply a filter based on a property of the entity I'd like to ask if it's even possible.
To Reproduce
As an example, I have have a many-to-one relation from
UsertoColourdenoted with the propertyuserColour. TheColourentity consists of a propertycolourCodewhich is of type string.In the CRUD controller for
User, let's say I have the following fields configured:Now I can use the
EntityFilteronuserColourto filter (which works), but if I wanted to filter onuserColour.colourCodeit doesn't seem to be that easy.Throwing the following error/stacktrace:
So am I missing something obvious here, either wrongly passing the property name or missing some options? Or is this either something that isn't working correctly, or maybe should a custom filter be used for such cases?
Additional context
Versions:
4.0.26.0.18.1