One problem is that you have made the address public. In Doctrine 2, you need to make your properties private or protected. D2 relies on this to implement lazy loading. Basically, your address never loads, although why you get an array is a puzzle. Are you initializing the address as an array in your constructor? Perhaps a copy / paste error?
You must have:
class User extends BaseUser { protected $address; public function getAddress() { return $this->address; }
You also need to make sure that the UserObject always has an Address object, or that the form will complain.
==================================================== ======
Looking at my pate, I see:
class User extends BaseUser { public function __construct() { $this->adresse = new \Doctrine\Common\Collections\ArrayCollection(); }
Which not only explains the unwanted array, but also spoils the base class of the user fos, since it is not called by the constructor.
I would suggest that you split your forms to the minimum user / address and get the job done. Then add your villi and everything else. In fact, just start by creating a simple user, and then add an address.
You did not show how you created the user object, but remember that it is up to you to ensure that the address object exists before the form begins. Teaching will not create it for you.
Cerad source share