浏览代码

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.
Fabien Potencier 13 年之前
父节点
当前提交
f57615b4a4
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/Symfony/Component/Form/Extension/Validator/Validator/DelegatingValidator.php

+ 1 - 1
src/Symfony/Component/Form/Extension/Validator/Validator/DelegatingValidator.php

@@ -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();