當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Element::getLabel方法代碼示例

本文整理匯總了PHP中Element::getLabel方法的典型用法代碼示例。如果您正苦於以下問題:PHP Element::getLabel方法的具體用法?PHP Element::getLabel怎麽用?PHP Element::getLabel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Element的用法示例。


在下文中一共展示了Element::getLabel方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: renderLabel

 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>';
     }
 }
開發者ID:Kemitestech,項目名稱:WordPress-Skeleton,代碼行數:11,代碼來源:SideBySide.php

示例2: renderLabel

 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>';
     }
 }
開發者ID:developmentDM2,項目名稱:The-Haute-Mess,代碼行數:12,代碼來源:SideBySide.php

示例3: renderLabel

 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> ';
 }
開發者ID:oytunistrator,項目名稱:php-bootstrap-form,代碼行數:12,代碼來源:SideBySide.php

示例4: renderLabel

 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>';
     }
 }
開發者ID:huangciyin,項目名稱:pH7-Social-Dating-CMS,代碼行數:20,代碼來源:View.php

示例5: html

 /**
  * 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);
 }
開發者ID:mncedim,項目名稱:htmlform,代碼行數:61,代碼來源:Element.php


注:本文中的Element::getLabel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。