merged branch kriswallsmith/form/validator-fix (PR #3082)

Commits
-------

aa58330 [Form] fixed flawed condition

Discussion
----------

[Form] fixed flawed condition

The validate() method always returns an object. The test is whether there are violations in that object.

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

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

by fabpot at 2012-01-10T21:22:10Z

What about removing the if condition altogether?

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

by kriswallsmith at 2012-01-10T21:23:55Z

This way we avoid creating an `ArrayIterator` for no reason.
This commit is contained in:
Fabien Potencier 2012-01-11 08:15:19 +01:00
commit f57615b4a4

View File

@ -76,7 +76,7 @@ class DelegatingValidator implements FormValidatorInterface
$child->addError($error);
}
}
} elseif ($violations = $this->validator->validate($form)) {
} elseif (count($violations = $this->validator->validate($form))) {
foreach ($violations as $violation) {
$propertyPath = $violation->getPropertyPath();
$template = $violation->getMessageTemplate();