protected function renderLabel(Element $element) { $label = $element->getLabel(); if (!empty($label)) { echo '<label class="control-label" for="', $element->getAttribute("id"), '">'; if ($element->isRequired()) { echo '<span class="required">* </span>'; } echo $label, '</label>'; } }
protected function renderLabel(Element $element) { $label = $element->getLabel(); if (!empty($label)) { //echo '<label class="control-label" for="', $element->getAttribute("id"), '">'; echo '<div class="rmfield" for="', $element->getAttribute("id"), '"><label>'; if ($element->isRequired()) { echo '<sup class="required">* </sup>'; } echo $label, '</label></div>'; } }
protected function renderLabel(Element $element) { $label = $element->getLabel(); if (empty($label)) { $label = ''; } echo ' <label class="text-left-xs col-xs-12 col-md-4 control-label" for="', $element->getAttribute("id"), '">'; if (!$this->noLabel && $element->isRequired()) { echo '<span class="required">* </span>'; } echo $label, '</label> '; }
protected function renderLabel(Element $element) { $label = $element->getLabel(); $id = $element->getID(); $description = $element->getDescription(); if (!empty($label) || !empty($description)) { echo '<div class="pfbc-label">'; if (!empty($label)) { echo '<label for="', $id, '">'; if ($element->isRequired()) { echo '<strong>*</strong> '; } echo $label, '</label>'; } if (!empty($description)) { echo '<em>', $description, '</em>'; } echo '</div>'; } }
/** * HTML renderer * @param Element $element * @param string $part [all|label|field|errors] * @param string $wrapper * @return string */ protected static function html(Element &$element, $part = 'all', $wrapper = 'div') { $label = $element->getLabel(false); $id = $element->getId(); //label if ($part == 'all' || $part == 'label') { $labelHtml = self::$templates['label']; $labelHtml = str_replace('{{id}}', $id, $labelHtml); $labelHtml = str_replace('{{text}}', $label, $labelHtml); if ($part == 'label') { return $labelHtml; } } //element itself if ($part == 'all' || $part == 'field') { $type = $element->getType(); $fieldHtml = $element->getTemplate(); //do element specific stuff if (is_callable("static::{$type}")) { //elements that have specific requirements have their own methods static::$type($element, $fieldHtml); } else { //the text based elements can all be handled by the text method. //to provide custom functionality for one, simply define a static method for it static::text($element, $fieldHtml); } //the hidden field type should never need the stuff below, might as well return here if ($part == 'field' || $element->getType() == self::TYPE_HIDDEN) { return $fieldHtml; } } //errors if ($part == 'all' || $part == 'errors') { $errors = $element->getErrors(false); $errorsHtml = ''; if (is_array($errors) && !empty($errors)) { $errorsHtml = '<ul class="error-list">'; foreach ($errors as $error) { $errorsHtml .= sprintf('<li>%s</li>', $error); } $errorsHtml .= '</ul>'; } if ($part == 'errors') { return $errorsHtml; } } //all together now! $html = '<%6$s id="%1$s_wrapper" class="%2$s-element mncedim-form-element"> %3$s %4$s %5$s </%6$s>'; if ($element->labelHidden() || in_array($element->getType(), array(self::TYPE_HIDDEN, self::TYPE_SUBMIT, self::TYPE_BUTTON))) { $labelHtml = ''; //label not required/wanted } return sprintf($html, $id, str_replace('_', '-', is_object($element->form) ? $element->form->getName() : 'form'), $type == self::TYPE_CHECKBOX ? $fieldHtml : $labelHtml, $type == self::TYPE_CHECKBOX ? $labelHtml : $fieldHtml, $element->hideErrors ? '' : $errorsHtml, $wrapper); }