[Form] Fix constraints could be null if not set
This commit is contained in:
parent
e5dda019ae
commit
f80e0eb143
@ -45,7 +45,7 @@ class FormValidator extends ConstraintValidator
|
||||
|
||||
// Validate the data against the constraints defined
|
||||
// in the form
|
||||
$constraints = $config->getOption('constraints');
|
||||
$constraints = $config->getOption('constraints', array());
|
||||
foreach ($constraints as $constraint) {
|
||||
foreach ($groups as $group) {
|
||||
if (in_array($group, $constraint->groups)) {
|
||||
|
@ -123,6 +123,17 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testNotExistingConstraintIndex()
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$form = new FormBuilder('name', '\stdClass', $this->dispatcher, $this->factory);
|
||||
$form = $form->setData($object)->getForm();
|
||||
|
||||
$this->validator->validate($form, new Form());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testValidateConstraintsEvenIfNoCascadeValidation()
|
||||
{
|
||||
$object = $this->getMock('\stdClass');
|
||||
|
Reference in New Issue
Block a user