[Form] Fixed: form children are always validated in group "Default"

This commit is contained in:
Bernhard Schussek 2012-01-30 13:42:13 +01:00
parent 916597eb29
commit 5aa5987aa4
2 changed files with 8 additions and 9 deletions

View File

@ -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);
}
}

View File

@ -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);
}