diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index f862970a7f..5792aa4082 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php @@ -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)) { diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index c440a0470a..1e30f237a5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -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');