Describe the bug
Can not display an unmapped field of type Datetime on index page of the crud entity.
Got The "dateEcheance" field does not exist in the "App\Entity\Facture" entity.
To Reproduce
Create a crud controller with an entity
Add a method on the entity like below :
public function getDateEcheance(): DateTime {
return new DateTime();
}
On the crud controller method configureFields add the following in the returned array
DateField::new('dateEcheance')
Then go to the index page.
(OPTIONAL) Additional context
If I replaced the method getDateEcheance by
public function getDateEcheance(): string {
return 'hello';
}
and
TextField::new('dateEcheance')
I can display the field with the value hello successfuly.
Thank you for any help
Symfony 5.1.2
Easyadmin v3.0.2
I have the similar problem.
I have entity Booking, which has relation OneToOne to Tour, and Tour has checkIn and title. I'm making CRUD controller for Booking.
On BookingCrudController::configureFields
$tourCheckIn = DateField::new('tour.checkIn'); // <--- doesn't work
$tourTitle = TextareaField::new('tour.title'); // <---- works
Error: The "tour.checkIn" field does not exist in the "App\Entity\Claim\Booking" entity.
See #3389 and the linked PR #3496 for a temporary solution (I've been using without issues since quite some time now).
It works for nested properties for sure @kozebobinka, but it might also work for unmapped properties @flim if it can extract the type by some other means, e.g. annotations or typed property 馃檪
@lukasluecke do you think that your PR #3496 is ready to be merged or do you still consider it experimental or draft? Thanks!
@javiereguiluz It鈥榮 stable enough, but I think we need to consider a more general solution (there are many more usages of the Doctrine metadata directly that might break or produce unexpected results with nested properties).
Either we migrate them all to be based on some part of the PropertyInfo component (which internally uses the Doctrine metadata, or any other information source like type annotations), or see my comment https://github.com/EasyCorp/EasyAdminBundle/issues/3389#issuecomment-657433913 for an alternative approach, and let me know what you prefer 馃檪