Describe the bug
Since EA 5.0.9, I am facing a really weird issue when using a CollectionField using __toString() of my entity to render the title of each item in the collection.
The same code works as expected in EA 5.0.8.
To Reproduce
yield CollectionField::new('timeSlots')->onlyOnForms()
->useEntryCrudForm(TimeSlotCrudController::class)
->renderExpanded()
->setRequired(true)
;
class TimeSlot
{
// ...
public function __toString(): string
{
return ucfirst(\IntlDateFormatter::formatObject($this->getStartDate(), 'eeee d à HH\'h\'mm'));
}
// ...
}
Error returned:
An exception has been thrown during the rendering of a template ("IntlDateFormatter::formatObject(): Argument #1 ($datetime) must be of type object, null given") in @EasyAdmin/crud/form_theme.html.twig at line 226.
Even if I replace __toString() to use another property of the entity, it's always returning null
Additional context
getStartDate() is NOT returning null it's a datetime and I can properly render the value if I add var_dump(ucfirst(\IntlDateFormatter::formatObject($this->getStartDate(), 'eeee d à HH\'h\'mm'))) just before the return.
I suspect changes in #7600 to be the cause of that issue.
cc @lacatoire
Describe the bug
Since EA 5.0.9, I am facing a really weird issue when using a
CollectionFieldusing__toString()of my entity to render the title of each item in the collection.The same code works as expected in EA 5.0.8.
To Reproduce
Error returned:
Even if I replace
__toString()to use another property of the entity, it's always returningnullAdditional context
getStartDate()is NOT returningnullit's a datetime and I can properly render the value if I addvar_dump(ucfirst(\IntlDateFormatter::formatObject($this->getStartDate(), 'eeee d à HH\'h\'mm')))just before thereturn.I suspect changes in #7600 to be the cause of that issue.
cc @lacatoire