コード例 #1
0
    public function render(Field $field, $renderedField)
    {
        $labelOpenTag = '<label>';
        $labelCloseTag = '</label>';
        $requiredStr = null;
        if ($field->hasRule('ch\\metanet\\formHandler\\rule\\RequiredRule') === true) {
            $requiredStr = ' <abbr title="required">*</abbr>';
        }
        if ($field->getLinkedLabel() === true) {
            $labelOpenTag = '<label for="' . $field->getId() . '">';
        }
        $errorHtml = null;
        $cssClasses = array();
        if ($field->hasErrors() === true) {
            $cssClasses[] = 'field-error';
            $errorHtml = '<div class="field-errors"><ul>';
            foreach ($field->getErrors() as $error) {
                $errorHtml .= '<li>' . $error . '</li>';
            }
            $errorHtml .= '</ul></div>';
        }
        return '<dl' . (count($cssClasses) > 0 ? ' class="' . implode(' ', $cssClasses) . '"' : null) . '>
			<dt>' . $labelOpenTag . $field->getLabel() . $requiredStr . $labelCloseTag . '</dt>
			<dd>' . $renderedField . $errorHtml . '</dd>
		</dl>';
    }
コード例 #2
0
 public function render(Field $field, $renderedField)
 {
     $errorHtmlBefore = null;
     $errorHtmlAfter = null;
     if ($field->hasErrors() === true) {
         $errorHtmlBefore = '<div class="input-error"><img class="input-error-mark" src="/images/icon-input-error.png" alt="!">';
         $errorHtmlAfter = '<ul class="input-error-list">';
         foreach ($field->getErrors() as $error) {
             $errorHtmlAfter .= '<li>' . $error . '</li>';
         }
         $errorHtmlAfter .= '</ul></div>';
     }
     return $errorHtmlBefore . $renderedField . $errorHtmlAfter;
 }