From 5aa5987aa423abff7b505c9eaa93f0180d9e82d4 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Mon, 30 Jan 2012 13:42:13 +0100 Subject: [PATCH] [Form] Fixed: form children are always validated in group "Default" --- .../Validator/Validator/DelegatingValidator.php | 7 +++---- .../Validator/Validator/DelegatingValidatorTest.php | 10 +++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Validator/Validator/DelegatingValidator.php b/src/Symfony/Component/Form/Extension/Validator/Validator/DelegatingValidator.php index dce76724c4..431205efc9 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Validator/DelegatingValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Validator/DelegatingValidator.php @@ -16,9 +16,10 @@ use Symfony\Component\Form\FormValidatorInterface; use Symfony\Component\Form\FormError; use Symfony\Component\Form\Util\VirtualFormAwareIterator; use Symfony\Component\Form\Exception\FormException; +use Symfony\Component\Form\Util\PropertyPath; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ValidatorInterface; use Symfony\Component\Validator\ExecutionContext; -use Symfony\Component\Form\Util\PropertyPath; class DelegatingValidator implements FormValidatorInterface { @@ -144,9 +145,7 @@ class DelegatingValidator implements FormValidatorInterface $propertyPath .= 'children'; - foreach (self::getFormValidationGroups($form) as $group) { - $graphWalker->walkReference($form->getChildren(), $group, $propertyPath, true); - } + $graphWalker->walkReference($form->getChildren(), Constraint::DEFAULT_GROUP, $propertyPath, true); } } diff --git a/tests/Symfony/Tests/Component/Form/Extension/Validator/Validator/DelegatingValidatorTest.php b/tests/Symfony/Tests/Component/Form/Extension/Validator/Validator/DelegatingValidatorTest.php index 1d16892dc6..e1081a2863 100644 --- a/tests/Symfony/Tests/Component/Form/Extension/Validator/Validator/DelegatingValidatorTest.php +++ b/tests/Symfony/Tests/Component/Form/Extension/Validator/Validator/DelegatingValidatorTest.php @@ -16,6 +16,7 @@ use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormError; use Symfony\Component\Form\Util\PropertyPath; use Symfony\Component\Form\Extension\Validator\Validator\DelegatingValidator; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ExecutionContext; @@ -809,12 +810,11 @@ class DelegatingValidatorTest extends \PHPUnit_Framework_TestCase ->getForm(); $form->add($this->getForm('firstName')); - $graphWalker->expects($this->at(0)) + $graphWalker->expects($this->once()) ->method('walkReference') - ->with($form->getChildren(), 'group1', 'children', true); - $graphWalker->expects($this->at(1)) - ->method('walkReference') - ->with($form->getChildren(), 'group2', 'children', true); + // validation happens in Default group, because the Callback + // constraint is in the Default group as well + ->with($form->getChildren(), Constraint::DEFAULT_GROUP, 'children', true); DelegatingValidator::validateFormChildren($form, $context); }