Пример #1
0
 /**
  * Render a form image
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $tag = $this->getTag();
     $placement = $this->getPlacement();
     $separator = $this->getSeparator();
     $name = $element->getFullyQualifiedName();
     $attribs = $this->getAttribs();
     $attribs['id'] = $element->getId();
     $image = $view->formImage($name, $element->getImageValue(), $attribs);
     if (null !== $tag) {
         $decorator = new HtmlTag();
         $decorator->setOptions(array('tag' => $tag));
         $image = $decorator->render($image);
     }
     switch ($placement) {
         case self::PREPEND:
             return $image . $separator . $content;
         case self::APPEND:
         default:
             return $content . $separator . $image;
     }
 }
Пример #2
0
 /**
  * Render a label
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $label = $this->getLabel();
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $tag = $this->getTag();
     $id = $this->getId();
     $class = $this->getClass();
     $options = $this->getOptions();
     if (empty($label) && empty($tag)) {
         return $content;
     }
     if (!empty($label)) {
         $options['class'] = $class;
         $label = $view->broker('formLabel')->direct($element->getFullyQualifiedName(), trim($label), $options);
     } else {
         $label = ' ';
     }
     if (null !== $tag) {
         $decorator = new HtmlTag();
         $decorator->setOptions(array('tag' => $tag, 'id' => $id . '-label'));
         $label = $decorator->render($label);
     }
     switch ($placement) {
         case self::APPEND:
             return $content . $separator . $label;
         case self::PREPEND:
             return $label . $separator . $content;
     }
 }