protected function renderErrorMessages(Element $element)
    {
        $html = '';

        // if we have error messages, then also render those
        if ($element instanceof AbstractFormField && sizeof($element->getErrorMessages()) > 0) {
            // render the error as title?
            if ($this->errorFormat == self::RENDER_AS_ATTRIBUTE) {
                // if the element is a form field, add the errors in the title tag
                $element->setAttribute($this->errorTagOrAttr, implode("\n", $element->getErrorMessages()));
            } elseif ($this->errorFormat == self::RENDER_AS_TAG) {
                $tag = new Tag($this->errorTagOrAttr);
                $tag->setInnerHtml(implode('<br />' . PHP_EOL, $element->getErrorMessages()));
                $html .= $tag->render();
            }
        }

        return $html;
    }
protected function renderErrorMessages(Element $element)
    {
        $html = '';

        // if we have error messages, then also render those
        if ($element instanceof AbstractFormField && sizeof($element->getErrorMessages()) > 0) {
            // render the error as title?
            if ($this->errorFormat == self::RENDER_AS_ATTRIBUTE) {
                // if the element is a form field, add the errors in the title tag
                $element->setAttribute($this->errorTagOrAttr, implode("\n", $element->getErrorMessages()));
            } elseif ($this->errorFormat == self::RENDER_AS_TAG) {
                $tag = new Tag($this->errorTagOrAttr);
                $tag->setInnerHtml(implode('<br />' . PHP_EOL, $element->getErrorMessages()));
                $html .= $tag->render();
            }
        }

        return $html;
    }
protected function renderErrorMessages ( Element $ element ) { $ html = '' ; // if we have error messages, then also render those if ( $ element instanceof AbstractFormField && sizeof ( $ element -> getErrorMessages ( ) ) > 0 ) { // render the error as title? if ( $ this -> errorFormat == self :: RENDER_AS_ATTRIBUTE ) { // if the element is a form field, add the errors in the title tag $ element -> setAttribute ( $ this -> errorTagOrAttr , implode ( "\n" , $ element -> getErrorMessages ( ) ) ) ; } elseif ( $ this -> errorFormat == self :: RENDER_AS_TAG ) { $ tag = new Tag ( $ this -> errorTagOrAttr ) ; $ tag -> setInnerHtml ( implode ( '<br />' . PHP_EOL , $ element -> getErrorMessages ( ) ) ) ; $ html .= $ tag -> render ( ) ; } } return $ html ; }
If the given element is a form field and it has error messages, then also render those and return them
in the expected format.
@param Element $element
@return string
If the given element is a form field and it has error messages then also render those and return them in the expected format .