I created a form of the customer.
CustomerType
$builder
->add('username', 'text', array(
'label' => 'customer.form.email',
))
->add('plainPassword', 'text', array(
'label' => 'customer.form.password',
))
->add('address', new AddressType)
;
To enter an address I want to use a second form.
AddressType
The class contains a form field. By default: 'data_class' => 'Customer Bundle\Entity\Address'
Result after submitting the form
Customer:
#id: 0
#username: 'test'
...
#address: ArrayCollection
I need:
Customer:
#id: 0
#username: 'test'
...
#address: Address
There is a simple way to this solution?
I found the solution:
->add('address', $this->addressType, array(
'data_class' => 'CustomerBundle\Entity\Address',
))
data_class must be set in the Customer Type