Index: Form.php =================================================================== --- Form.php (revision 19962) +++ Form.php (working copy) @@ -2181,6 +2181,16 @@ $this->_errorMessages = array(); return $this; } + + /** + * Determine whether there are custom error messages + * + * @return boolean + */ + public function hasErrorMessages() + { + return !empty($this->_errorMessages); + } /** * Mark the element as being in a failed validation state Index: Form/Decorator/FormErrors.php =================================================================== --- Form/Decorator/FormErrors.php (revision 19962) +++ Form/Decorator/FormErrors.php (working copy) @@ -377,18 +377,24 @@ return $content; } - foreach ($errors as $name => $list) { - $element = $form->$name; - if ($element instanceof Zend_Form_Element) { - $element->setView($view); - $content .= $this->getMarkupListItemStart() - . $this->renderLabel($element, $view) - . $view->formErrors($list, $this->getOptions()) - . $this->getMarkupListItemEnd(); - } elseif (!$this->ignoreSubForms() && ($element instanceof Zend_Form)) { - $content .= $this->getMarkupListStart() - . $this->_recurseForm($element, $view) - . $this->getMarkupListEnd(); + if ($form->hasErrorMessages()) { + $content .= $this->getMarkupListStart() + . $view->formErrors($errors, $this->getOptions()) + . $this->getMarkupListEnd(); + } else { + foreach ($errors as $name => $list) { + $element = $form->$name; + if ($element instanceof Zend_Form_Element) { + $element->setView($view); + $content .= $this->getMarkupListItemStart() + . $this->renderLabel($element, $view) + . $view->formErrors($list, $this->getOptions()) + . $this->getMarkupListItemEnd(); + } elseif (!$this->ignoreSubForms() && ($element instanceof Zend_Form)) { + $content .= $this->getMarkupListStart() + . $this->_recurseForm($element, $view) + . $this->getMarkupListEnd(); + } } }