merged branch bschussek/issue3219 (PR #3221)

Commits
-------

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

Discussion
----------

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

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3219
Todo: -

![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue3219)

---------------------------------------------------------------------------

by bschussek at 2012-01-30T12:44:43Z

@craue: Can you verify whether this PR fixes your problem?

---------------------------------------------------------------------------

by craue at 2012-01-30T12:53:59Z

Yeah, it does. 👍
This commit is contained in:
Fabien Potencier 2012-01-30 15:02:48 +01:00
commit 2662ab8ee7
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);
}