Closed
Description
With #3128, using cascade_validation
doesn't work as expected when validation_groups
are involved, while using @Valid
would.
Let me try to illustrate the issue:
<?php
// main entity
class Author {
/**
* @Assert\NotBlank(groups={"Default", "bla"})
*/
protected $name;
/**
* @var Address
*/
protected $address;
// ...
}
// child entity
class Address {
/**
* @Assert\NotBlank(groups={"Default", "bla"})
*/
protected $street;
// ...
}
// main form
class CreateAuthorFormType {
public function buildForm(FormBuilder $builder, array $options) {
$builder->add('name');
$builder->add('address', 'form_type_address', array(
'data_class' => get_class(new Address()),
));
}
}
// child form
class EditAddressFormType {
public function buildForm(FormBuilder $builder, array $options) {
$builder->add('street');
}
public function getName() {
return 'form_type_address';
}
}
// in a Controller
$author = new Author();
$author->setAddress(new Address());
$createAuthorForm = $this->createForm(new CreateAuthorFormType(), $author, array(
'validation_groups' => 'bla',
'cascade_validation' => true,
));
// ...
if ($createAuthorForm->isValid()) {
// ISSUE: will be valid even if street is empty
}
Metadata
Metadata
Assignees
Labels
No labels