EasyCorp / EasyAdminBundle

EasyAdmin is a fast, beautiful and modern admin generator for Symfony applications.
MIT License
3.99k stars 1.01k forks source link

Association Entity Return value must be of type string, null returned #6274

Closed Luvelnet closed 3 weeks ago

Luvelnet commented 3 weeks ago

I have an application with several relationships, for example Customer and CustomerType. When I go to create or edit an entity there is no problem, but in the list, I get the following error:

App\Entity\CustomerType::getType(): Return value must be of type string, null returned

My CustomerType Entity has its string method:

public function __toString(): string
{
         return $this->getType();
}

They have always worked for me, but now I'm having this problem. Is anyone experiencing the same thing?

The field used is: AssociationField::new('customerType','Customer Type')->setColumns(2).

On the other hand, if I return the Id in the __toString() method, there is no problem. Could it be because of lazy loading? Any way to avoid this?

Thanks.

Luvelnet commented 3 weeks ago

I have solved the problem by reverting to a previous version of doctrine. Exactly: 2.19.4 => 2.16.2. I honestly don't know what's happening, but something must have changed in how the entities relate and I've missed it.

I'll review it and if I come to any conclusion, I'll leave it noted here in case it helps someone.