Reputation: 3677
When i submit a form of Zend Framework 2, i would like to check in each single input has any errors, and if so, do something in the view.
Is there any "hasError()" (of the single input element) method? For the Form, there is the "isValid()" method.
Thanks
Upvotes: 1
Views: 755
Reputation: 703
Use getMessages() and check if variable is empty.
foreach ($form as $element) {
$messages = $element->getMessages();
if (!empty($messages)) {
// do something
}
}
Upvotes: 2