public function decorate(\Sighhat\Form\Element\Base $element)
 {
     $ret = $this->childStart();
     if ($opt = $element->getDecoratorOptions()) {
         if (isset($opt['wrapperAttr'])) {
             $i = '';
             foreach ($opt['wrapperAttr'] as $name => $value) {
                 $i .= ' ' . $name . '="' . $value . '"';
             }
             $ret = rtrim($ret, '>');
             $ret .= $i . '>';
         }
     }
     $lWrap = false;
     if ($label = $element->getLabel()) {
         $lWrap = (bool) $label->type == \Sighhat\Form\Element\Base::LABEL_FOR;
         if ($lWrap) {
             $ret .= sprintf('<label for="%s">%s</label>', $element->getName(), $label->text);
         } else {
             $ret .= sprintf('<label>%s', $label->text);
         }
     }
     if ($element->hasError()) {
         $ret .= '<div class="error">';
         $ret .= $element->getError() . '<br />';
     }
     $ret .= $element->render();
     if ($element->hasError()) {
         $ret .= '</div>';
     }
     if (!$lWrap && $label) {
         $ret .= '</label>';
     }
     return $ret . $this->childEnd();
 }
Beispiel #2
0
 public function setErrors(ElementAbstract $element)
 {
     $this->_errors[$element->getName()] = $element->getError();
     return $this;
 }