/** * Recurse through a form object, rendering errors * * @param \Zend\Form\Form $form * @param \Zend\View\Renderer\RendererInterface $view * @return string */ protected function _recurseForm(Form\Form $form, View $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 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(); } } elseif ($subitem instanceof Form\Form && !$this->ignoreSubForms()) { $content .= $this->getMarkupListStart() . $this->_recurseForm($subitem, $view) . $this->getMarkupListEnd(); } } return $content; }