Skip to content

Commit

Permalink
Merge pull request #316 from Kunstmaan/fix_form_errors
Browse files Browse the repository at this point in the history
fix form errors for symfony 2.5
  • Loading branch information
kimausloos committed Jul 4, 2014
2 parents 67db719 + 3bd827d commit cba4cf0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Helper/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ class FormHelper
*/
public function hasRecursiveErrorMessages(FormView $formView)
{
if (!empty($formView->vars['errors'])) {
$errors = $formView->vars['errors'];

if (is_object($errors) && $errors instanceof \Traversable) {
$errors = iterator_to_array($errors);
}

if (!empty($errors)) {
return true;
}

if ($formView->count()) {
foreach ($formView->children as $child) {
if ($this->hasRecursiveErrorMessages($child)) {
Expand All @@ -49,11 +56,17 @@ public function getRecursiveErrorMessages($formViews, array &$errors = array())
$this->getRecursiveErrorMessages($formView, $errors);
}
} else {
$errors = $formViews->vars['errors'];

if (is_object($errors) && $errors instanceof \Traversable) {
$errors = iterator_to_array($errors);
}

/**
* @var $formViews FormView
* @var $error FormError
*/
foreach ($formViews->vars['errors'] as $error) {
foreach ($errors as $error) {

$template = $error->getMessageTemplate();
$parameters = $error->getMessageParameters();
Expand Down

0 comments on commit cba4cf0

Please sign in to comment.