I have a form that combines two entities (User and Profile).
Validation seems to work on the first part of the form that comes form the User Entity and is the basis
According to form type documentation you can also use Valid
constraint instead of cascade_validation
option.
$builder->add('children', 'collection', array(
'type' => new ChildType(),
'constraints' => array(new Valid()),
));
Example from the owner entity:
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="Child", ...)
* @Assert\Valid()
*/
private $children
I was looking for the exact same thing and here is what I found
http://symfony.com/doc/master/book/forms.html#forms-embedding-single-object
You need to tell the main entity to validate it's sub entities like so:
/**
* @Assert\Type(type="AppBundle\Entity\Category")
* @Assert\Valid()
*/
private $subentity;
I've tested this on symfony 2.8 and it works.