Example #1
0
 /**
  * Recurse through a form object, rendering errors
  *
  * @param  Zend_Form $form
  * @param  Zend_View_Interface $view
  * @return string
  */
 protected function _recurseForm(Zend_Form $form, Zend_View_Interface $view)
 {
     $content = '';
     $custom = $form->getCustomMessages();
     if ($this->getShowCustomFormErrors() && count($custom)) {
         $content .= $this->getMarkupListItemStart() . $view->formErrors($custom, $this->getOptions()) . $this->getMarkupListItemEnd();
     }
     foreach ($form->getElementsAndSubFormsOrdered() as $subitem) {
         if ($subitem instanceof Zend_Form_Element && !$this->getOnlyCustomFormErrors()) {
             $messages = $subitem->getMessages();
             if (count($messages)) {
                 $subitem->setView($view);
                 $content .= $this->getMarkupListItemStart() . $this->renderLabel($subitem, $view) . $view->formErrors($messages, $this->getOptions()) . $this->getMarkupListItemEnd();
             }
         } else {
             if ($subitem instanceof Zend_Form && !$this->ignoreSubForms()) {
                 $content .= $this->getMarkupListStart() . $this->_recurseForm($subitem, $view) . $this->getMarkupListEnd();
             }
         }
     }
     return $content;
 }
 /**
  * Recurse through a form object, rendering errors
  * 
  * @param  Zend_Form $form 
  * @param  Zend_View_Interface $view 
  * @return string
  */
 protected function _recurseForm(Zend_Form $form, Zend_View_Interface $view)
 {
     $content = '';
     $errors = $form->getMessages();
     if ($form instanceof Zend_Form_SubForm || @$form->isSubForm) {
         $name = $form->getName();
         if (1 == count($errors) && array_key_exists($name, $errors)) {
             $errors = $errors[$name];
         }
     }
     if (empty($errors)) {
         return $content;
     }
     foreach ($errors as $name => $list) {
         $element = $form->{$name};
         if (null === $element && is_numeric($name)) {
             $content .= $this->getMarkupListItemStart() . $view->formErrors((array) $list, $this->getOptions()) . $this->getMarkupListItemEnd();
         } else {
             if ($element instanceof Zend_Form_Element) {
                 $element->setView($view);
                 $content .= $this->getMarkupListItemStart() . ($this->_skipLabels ? '' : $this->renderLabel($element, $view)) . $view->formErrors($list, $this->getOptions()) . $this->getMarkupListItemEnd();
             } elseif (!$this->ignoreSubForms() && $element instanceof Zend_Form) {
                 $content .= $this->_recurseForm($element, $view);
             }
         }
     }
     return $content;
 }