getElement(); if ((!$form instanceof Zend_Form) && (!$form instanceof Zend_Form_DisplayGroup)) { return $content; } $firstSubForm = current($form->getSubForms()); if (!($firstSubForm instanceof Qs_Form_SubForm)) { return $content; } $elementContent = ''; $separator = $this->getSeparator(); $translator = $form->getTranslator(); $items = array(); $view = $form->getView(); /** @var Qs_Form_Decorator_HtmlTag $th */ $th = (new Qs_Form_Decorator_HtmlTag())->setElement($this->getElement())->setTag('th'); /** @var Qs_Form_Decorator_HtmlTag $labelDecorator */ $labelDecorator = (new Qs_Form_Decorator_HtmlTag())->setElement($this->getElement())->setTag('label'); /** @var Zend_Form_Element|Zend_Form_DisplayGroup $item */ foreach ($firstSubForm as $item) { if ($item instanceof Zend_Form_Element) { $labelDecorator->setOption('class', $item->isRequired() ? 'required' : 'optional'); $label = $item->getLabel(); } elseif ($item instanceof Zend_Form_DisplayGroup) { $labelDecorator->setOption('class', 'optional'); $label = $item->getLegend(); } else { continue; } $item->setView($view)->setTranslator($translator); if (($decorator = $item->getDecorator('HtmlTag')) && ($class = $decorator->getOption('class'))) { $th->setOption('class', $class); } $label = trim($label); $items[]= $th->render($label ? $labelDecorator->render($view->escape($label)) : ' '); } $elementContent .= implode($separator, $items); switch ($this->getPlacement()) { case self::PREPEND: return $elementContent . $separator . $content; case self::APPEND: default: return $content . $separator . $elementContent; } } }