10000 [Form] Created FormErrorBag by wouterj · Pull Request #9099 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Created FormErrorBag #9099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[INVALID] Tried to fix the tests
  • Loading branch information
wouterj committed Dec 28, 2013
commit f002137b9b7a0bf21cb7f2f131d1f8f589800dc9
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php if ($errors): ?>
<?php if (count($errors)): ?>
<ul>
<?php foreach ($errors as $error): ?>
<li><?php echo $error->getMessage() ?></li>
Expand Down
8 changes: 8 additions & 0 deletions src/Symfony/Component/Form/FormErrorBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ public function rewind()

public function valid()
{
while (current($this->errors) instanceof FormErrorBag) {
$this->next();

if (!$this->valid()) {
return false;
}
}

return null !== key($this->errors);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Form/Tests/FormErrorBagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public function testRecursivelyIterateErrors()
$this->assertInstanceof('Symfony\Component\Form\FormError', $error);
$this->assertEquals(next($messages), $error->getMessage());
}

$this->assertFalse(next($messages), 'got all errors');
}

public function testCountingErrors()
Expand Down
0