[Form] Fixed: form children are always validated in group "Default"
This commit is contained in:
parent
916597eb29
commit
5aa5987aa4
@ -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