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:
commit
2662ab8ee7
@ -16,9 +16,10 @@ use Symfony\Component\Form\FormValidatorInterface;
|
|||||||
use Symfony\Component\Form\FormError;
|
use Symfony\Component\Form\FormError;
|
||||||
use Symfony\Component\Form\Util\VirtualFormAwareIterator;
|
use Symfony\Component\Form\Util\VirtualFormAwareIterator;
|
||||||
use Symfony\Component\Form\Exception\FormException;
|
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\ValidatorInterface;
|
||||||
use Symfony\Component\Validator\ExecutionContext;
|
use Symfony\Component\Validator\ExecutionContext;
|
||||||
use Symfony\Component\Form\Util\PropertyPath;
|
|
||||||
|
|
||||||
class DelegatingValidator implements FormValidatorInterface
|
class DelegatingValidator implements FormValidatorInterface
|
||||||
{
|
{
|
||||||
@ -144,9 +145,7 @@ class DelegatingValidator implements FormValidatorInterface
|
|||||||
|
|
||||||
$propertyPath .= 'children';
|
$propertyPath .= 'children';
|
||||||
|
|
||||||
foreach (self::getFormValidationGroups($form) as $group) {
|
$graphWalker->walkReference($form->getChildren(), Constraint::DEFAULT_GROUP, $propertyPath, true);
|
||||||
$graphWalker->walkReference($form->getChildren(), $group, $propertyPath, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ use Symfony\Component\Form\FormBuilder;
|
|||||||
use Symfony\Component\Form\FormError;
|
use Symfony\Component\Form\FormError;
|
||||||
use Symfony\Component\Form\Util\PropertyPath;
|
use Symfony\Component\Form\Util\PropertyPath;
|
||||||
use Symfony\Component\Form\Extension\Validator\Validator\DelegatingValidator;
|
use Symfony\Component\Form\Extension\Validator\Validator\DelegatingValidator;
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\ConstraintViolation;
|
use Symfony\Component\Validator\ConstraintViolation;
|
||||||
use Symfony\Component\Validator\ExecutionContext;
|
use Symfony\Component\Validator\ExecutionContext;
|
||||||
|
|
||||||
@ -809,12 +810,11 @@ class DelegatingValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
->getForm();
|
->getForm();
|
||||||
$form->add($this->getForm('firstName'));
|
$form->add($this->getForm('firstName'));
|
||||||
|
|
||||||
$graphWalker->expects($this->at(0))
|
$graphWalker->expects($this->once())
|
||||||
->method('walkReference')
|
->method('walkReference')
|
||||||
->with($form->getChildren(), 'group1', 'children', true);
|
// validation happens in Default group, because the Callback
|
||||||
$graphWalker->expects($this->at(1))
|
// constraint is in the Default group as well
|
||||||
->method('walkReference')
|
->with($form->getChildren(), Constraint::DEFAULT_GROUP, 'children', true);
|
||||||
->with($form->getChildren(), 'group2', 'children', true);
|
|
||||||
|
|
||||||
DelegatingValidator::validateFormChildren($form, $context);
|
DelegatingValidator::validateFormChildren($form, $context);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user