merged branch bschussek/issue7371 (PR #7918)
This PR was merged into the 2.1 branch.
Discussion
----------
[Form] Fixed: String validation groups are never interpreted as callbacks
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #7371
| License | MIT
| Doc PR | -
Commits
-------
7b2ebbf
[Form] Fixed: String validation groups are never interpreted as callbacks
This commit is contained in:
commit
1510faa96a
@ -181,7 +181,7 @@ class FormValidator extends ConstraintValidator
|
|||||||
$groups = $form->getConfig()->getOption('validation_groups');
|
$groups = $form->getConfig()->getOption('validation_groups');
|
||||||
|
|
||||||
if (null !== $groups) {
|
if (null !== $groups) {
|
||||||
if (is_callable($groups)) {
|
if (!is_string($groups) && is_callable($groups)) {
|
||||||
$groups = call_user_func($groups, $form);
|
$groups = call_user_func($groups, $form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,6 +302,24 @@ class FormValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->validator->validate($form, new Form());
|
$this->validator->validate($form, new Form());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDontExecuteFunctionNames()
|
||||||
|
{
|
||||||
|
$context = $this->getExecutionContext();
|
||||||
|
$graphWalker = $context->getGraphWalker();
|
||||||
|
$object = $this->getMock('\stdClass');
|
||||||
|
$options = array('validation_groups' => 'header');
|
||||||
|
$form = $this->getBuilder('name', '\stdClass', $options)
|
||||||
|
->setData($object)
|
||||||
|
->getForm();
|
||||||
|
|
||||||
|
$graphWalker->expects($this->once())
|
||||||
|
->method('walkReference')
|
||||||
|
->with($object, 'header', 'data', true);
|
||||||
|
|
||||||
|
$this->validator->initialize($context);
|
||||||
|
$this->validator->validate($form, new Form());
|
||||||
|
}
|
||||||
|
|
||||||
public function testHandleClosureValidationGroups()
|
public function testHandleClosureValidationGroups()
|
||||||
{
|
{
|
||||||
$context = $this->getExecutionContext();
|
$context = $this->getExecutionContext();
|
||||||
|
Reference in New Issue
Block a user