当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractElement::getLabel方法代码示例

本文整理汇总了PHP中Magento\Framework\Data\Form\Element\AbstractElement::getLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractElement::getLabel方法的具体用法?PHP AbstractElement::getLabel怎么用?PHP AbstractElement::getLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Data\Form\Element\AbstractElement的用法示例。


在下文中一共展示了AbstractElement::getLabel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * Checkbox render function
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     /** @var \Magento\Framework\Data\Form\Element\Checkbox $checkbox */
     $checkbox = $this->_elementFactory->create('checkbox', array('data' => $element->getData()));
     $checkbox->setForm($element->getForm());
     $elementHtml = sprintf('<div class="field no-label field-%s with-note">' . '<div class="control">' . '<div class="nested">' . '<div class="field choice"> %s' . '<label class="label" for="%s">%s</label>' . '<p class="note">%s</p>' . '</div>' . '</div>' . '</div>' . '</div>', $element->getHtmlId(), $checkbox->getElementHtml(), $element->getHtmlId(), $element->getLabel(), $element->getNote());
     return $elementHtml;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:Checkbox.php

示例2: render

 /**
  * render separator config row
  * 
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $fieldConfig = $element->getFieldConfig();
     $htmlId = $element->getHtmlId();
     $html = '<tr id="row_' . $htmlId . '">' . '<td class="label" colspan="3">';
     $html .= '<div style="border-bottom: 1px solid #dfdfdf;
     font-size: 15px;
     color: #666;
     border-left: #CCC solid 5px;
     padding: 2px 12px;
     text-align: left !important;
     margin-left: 10%;
     margin-top: 20px;">';
     $html .= $element->getLabel();
     $html .= '</div></td></tr>';
     return $html;
 }
开发者ID:vasuscoin,项目名称:brand,代码行数:23,代码来源:Heading.php

示例3: render

 /**
  * @param AbstractElement $element
  * @return string
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function render(AbstractElement $element)
 {
     $countryId = false;
     $isRegionRequired = false;
     if ($country = $element->getForm()->getElement('country_id')) {
         $countryId = $country->getValue();
         $isRegionRequired = $this->_directoryHelper->isRegionRequired($countryId);
     }
     $html = '<div class="field field-region ' . ($isRegionRequired ? 'required' : '') . '">' . "\n";
     $regionCollection = false;
     if ($countryId) {
         if (!isset(self::$_regionCollections[$countryId])) {
             self::$_regionCollections[$countryId] = $this->_countryFactory->create()->setId($countryId)->getLoadedRegionCollection()->toOptionArray();
         }
         $regionCollection = self::$_regionCollections[$countryId];
     }
     $regionId = intval($element->getForm()->getElement('region_id')->getValue());
     $htmlAttributes = $element->getHtmlAttributes();
     foreach ($htmlAttributes as $key => $attribute) {
         if ('type' === $attribute) {
             unset($htmlAttributes[$key]);
             break;
         }
     }
     // Output two elements - for 'region' and for 'region_id'.
     // Two elements are needed later upon form post - to properly set data to address model,
     // otherwise old value can be left in region_id attribute and saved to DB.
     // Depending on country selected either 'region' (input text) or 'region_id' (selectbox) is visible to user
     $regionHtmlName = $element->getName();
     $regionIdHtmlName = str_replace('region', 'region_id', $regionHtmlName);
     $regionHtmlId = $element->getHtmlId();
     $regionIdHtmlId = str_replace('region', 'region_id', $regionHtmlId);
     if ($isRegionRequired) {
         $element->addClass('required-entry');
     }
     if ($regionCollection && count($regionCollection) > 0) {
         $elementClass = $element->getClass();
         $html .= '<label class="label" for="' . $regionIdHtmlId . '"><span>' . $element->getLabel() . '</span>' . '</label>';
         $html .= '<div class="control">';
         $html .= '<select id="' . $regionIdHtmlId . '" name="' . $regionIdHtmlName . '" ' . $element->serialize($htmlAttributes) . '>' . "\n";
         foreach ($regionCollection as $region) {
             $selected = $regionId == $region['value'] ? ' selected="selected"' : '';
             $regionVal = 0 == $region['value'] ? '' : (int) $region['value'];
             $html .= '<option value="' . $regionVal . '"' . $selected . '>' . $this->_escaper->escapeHtml(__($region['label'])) . '</option>';
         }
         $html .= '</select>' . "\n";
         $html .= '<input type="hidden" name="' . $regionHtmlName . '" id="' . $regionHtmlId . '" value=""/>';
         $html .= '</div>';
         $element->setClass($elementClass);
     } else {
         $html .= '<label class="label" for="' . $regionHtmlId . '"><span>' . $element->getLabel() . '</span></label>';
         $html .= '<div class="control">';
         $html .= '<input id="' . $regionHtmlId . '" name="' . $regionHtmlName . '" value="' . $element->getEscapedValue() . '" ' . $element->serialize($htmlAttributes) . "/>" . "\n";
         $html .= '<input type="hidden" name="' . $regionIdHtmlName . '" id="' . $regionIdHtmlId . '" value=""/>';
         $html .= '</div>' . "\n";
     }
     $html .= '</div>' . "\n";
     return $html;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:65,代码来源:Region.php

示例4: aroundGetLabelHtml

 /**
  * 2015-12-13
  * Отличия от модифицируемого метода
  * @see \Magento\Framework\Data\Form\Element\AbstractElement::getLabelHtml():
  * 1) Добавляем свои классы для Font Awesome.
  * 2) При использовании Font Awesome не добавляем исходную подпись
  * (значением которой является класс Font Awesome)
  * и выводим, по сути, пустые теги <label><span></span></label>.
  * 3) Добавляем атрибут title.
  * 2015-12-28
  * 4) Добавляем класс, соответствующий типу элемента.
  *
  * Пример использования Font Awesome: https://github.com/mage2pro/core/tree/7cb37ab2c4d728bc20d29ca3c7c643e551f6eb0a/Framework/Data/Form/Element/Font.php#L40
  *
  * @see \Df\Framework\Form\Element\Font::onFormInitialized()
  * @see \Magento\Framework\Data\Form\Element\AbstractElement::getLabelHtml()
  * @param Sb|E $sb
  * @param \Closure $proceed
  * @param string|null $idSuffix
  * @return string
  */
 public function aroundGetLabelHtml(Sb $sb, \Closure $proceed, $idSuffix = '')
 {
     /** @var string|null|Phrase $label */
     $label = $sb->getLabel();
     /** @var string $result */
     if (is_null($label)) {
         $result = '';
     } else {
         $label = (string) $label;
         /**
          * 2015-12-25
          * @see \Magento\Framework\Data\Form\Element\Multiline::getLabelHtml()
          * имеет другое значение по-умолчанию параметра $idSuffix:
          * public function getLabelHtml($suffix = 0)
          * https://github.com/magento/magento2/blob/2.0.0/lib/internal/Magento/Framework/Data/Form/Element/Multiline.php#L59
          */
         if ('' === $idSuffix && $sb instanceof Multiline) {
             $idSuffix = 0;
         }
         /** @var bool $isFontAwesome */
         $isFontAwesome = df_starts_with($label, 'fa-');
         /** @var string[] $classA */
         $classA = ['label', 'admin__field-label', 'df-element-' . $sb->getType()];
         if ($isFontAwesome) {
             $classA[] = 'fa';
             $classA[] = $label;
             $label = '';
         }
         /** @var array(string => string) $params */
         $params = ['class' => df_cc_s($classA), 'for' => $sb->getHtmlId() . $idSuffix, 'data-ui-id' => E::uidSt($sb, 'label')];
         /** @var string $title */
         $title = (string) $sb->getTitle();
         if ($title !== $label) {
             $params['title'] = $title;
         }
         $result = df_tag('label', $params, df_tag('span', [], $label)) . "\n";
     }
     return $result;
 }
开发者ID:mage2pro,项目名称:core,代码行数:60,代码来源:AbstractElement.php

示例5: render

 /**
  * Render element html
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     return sprintf('<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5"><h4 id="%s">%s</h4></td></tr>', $element->getHtmlId(), $element->getHtmlId(), $element->getLabel());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:Heading.php


注:本文中的Magento\Framework\Data\Form\Element\AbstractElement::getLabel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。