Last active
December 12, 2015 08:18
-
-
Save adatta02/4743038 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function getAllErrors($children, $template = true) { | |
$this->getAllFormErrors($children); | |
return $this->allErrors; | |
} | |
private function getAllFormErrors($children, $template = true) { | |
foreach ($children as $child) { | |
if ($child->hasErrors()) { | |
$vars = $child->createView()->getVars(); | |
$errors = $child->getErrors(); | |
foreach ($errors as $error) { | |
$this->allErrors[$vars["name"]][] = $this->convertFormErrorObjToString($error); | |
} | |
} | |
if ($child->hasChildren()) { | |
$this->getAllErrors($child); | |
} | |
} | |
} | |
private function convertFormErrorObjToString($error) { | |
$errorMessageTemplate = $error->getMessageTemplate(); | |
foreach ($error->getMessageParameters() as $key => $value) { | |
$errorMessageTemplate = str_replace($key, $value, $errorMessageTemplate); | |
} | |
return $errorMessageTemplate; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment