Our blog
Zend Form Remove Error Messages
Sometimes you don't want to display the error messages for a form. I have tried to find the proper solution to remove validtion error messages and haven't found what I would regard as the proper solution.
However what does work for me is to loop through any elements that I want to remove the error messages for and remove the error message decorator like this:
-
foreach($subforms['empty'] as $sf){
-
$elements = $sf->getElements();
-
foreach($elements as $e){
-
$e->removeDecorator('Errors');
-
}
-
}
In this context I have filtered out all the subforms where all inputs are empty and will then remove the error messages from those sub forms.
If you are interested, here is the method I use to validate subforms and separate out valid, invalid and totally empty sub forms.
-
public function validateSubForms($data){
-
$subforms = $this->getSubForms();
-
foreach($subforms as $sf){
-
if($sf->isValid($data)){
-
$valid[]=$sf;
-
}else{
-
$error_other_than_empty = false;
-
$elements = $sf->getElements();
-
foreach($elements as $e){
-
$errors = $e->getErrors();
-
foreach($errors as $er){
-
// EC_Debug::diedump($er);
-
if($er !='isEmpty'){
-
$error_other_than_empty = true;
-
break(2);
-
}
-
}
-
}
-
if($error_other_than_empty){
-
$invalid[]=$sf;
-
}else{
-
$empty[]=$sf;
-
}
-
}
-
}
-
'valid' => $valid,
-
'empty'=>$empty,
-
'invalid' => $invalid
-
);
-
}
More...
Zend Framework: Creating custom Zend form « Zend Framework
Grouping Form errors for display purpose in Zend Framework
Handling Zend Framework Form error messages
Zend Framework Dojo Form decorators example and usage « Zend Framework
Handling Zend Framework Form error messages
Playing with Zend Framework
Grouping Form errors for display purpose in Zend Framework « Zend ...
Installing apache 2.2, proftpd, fcgi and mysql
Soap, XmlRpc, PHP, Rest API, Trading, ZF, Zend Framework ...
RSS Feed