Newscoop\Form\Decorator\Label::render PHP Method

render() public method

Render a label
public render ( string $content ) : string
$content string
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();
        $tagClass = method_exists($this, 'getTagClass') ? $this->getTagClass() : false;
        $id = $this->getId();
        $class = $this->getClass();
        $options = $this->getOptions();
        if (empty($label) && empty($tag)) {
            return $content;
        }
        if (in_array(get_class($element), $this->_hiddenLabels)) {
            $label = '';
        } elseif (!empty($label)) {
            $options['class'] = $class;
            $label = $view->formLabel($element->getFullyQualifiedName(), trim($label), $options);
        } else {
            $label = ' ';
        }
        if (null !== $tag) {
            require_once 'Zend/Form/Decorator/HtmlTag.php';
            $decorator = new Zend_Form_Decorator_HtmlTag();
            if ($tagClass && null !== $this->_tagClass) {
                $decorator->setOptions(array('tag' => $tag, 'id' => $id . '-label', 'class' => $tagClass));
            } else {
                $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;
        }
    }
Label