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
I spent an age searching and found that it was adding 'cascade_validation' => true to the setDefaults() array in my parent type's class that fixed it (as mentioned already in the thread). This causes the entity constraint validation to trigger in the child types shown in the form. e.g.
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
...
'cascade_validation' => true,
));
}
For collections, also make sure to add 'cascade_validation' => true to the $options array for the collection field on the form. e.g.
$builder->add('children', 'collection', array(
'type' => new ChildType(),
'cascade_validation' => true,
));
This will have the UniqueEntity validation take place as it should in the child entity used in the collection.