symfony/symfony — Issue #3155: Form ChoiceList Exception not so clear
Author: OlivierCuyp
Created: 2012-01-19 16:08:26+00:00
State: open

Hi,

I created an entity with several relationships.
I used the CRUD generator and tried to access the edit page of the entity.
I recieved this exception :

```shell
Entities passed to the choice field must have a "__toString()"
method defined (or you can also override the "property" option).
```

I must have made a typo in one of my related entities since they all have a __toString function.
It would be nice to know which is the class causing the problem.

I was about to make a PR to change src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php like this :

```PHP
// ...
// line 108
throw new FormException($this->classMetadata->getName() . '\'s entities passed to the choice field must have a "__toString()" method defined (or you can also override the "property" option).');
//...
```
(I just added the name of the class in the exception message with : $this->classMetadata->getName())
But since I'm still a bit to fresh with Symfony, I'm not sure it is the best palce and/or way to do it.

Let me know if I can help improving this.