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


PHP AbstractElement::addClass方法代码示例

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


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

示例1: testRemoveClass

 /**
  * @covers \Magento\Framework\Data\Form\Element\AbstractElement::removeClass()
  */
 public function testRemoveClass()
 {
     $oldClass = 'old_class';
     $newClass = 'new_class';
     $oneMoreClass = 'some_class';
     $this->_model->addClass($oldClass);
     $this->_model->addClass($oneMoreClass);
     $this->_model->addClass($newClass);
     $this->_model->removeClass($oneMoreClass);
     $this->assertEquals(' ' . $oldClass . ' ' . $newClass, $this->_model->getClass());
 }
开发者ID:,项目名称:,代码行数:14,代码来源:

示例2: render

 /**
  * @param AbstractElement $element
  * @return string
  */
 public function render(AbstractElement $element)
 {
     $element->addClass('element-value-changer');
     $html = '&nbsp;<span class="rule-param rule-param-new-child"' . ($element->getParamId() ? ' id="' . $element->getParamId() . '"' : '') . '>';
     $html .= '<a href="javascript:void(0)" class="label">';
     $html .= $element->getValueName();
     $html .= '</a><span class="element">';
     $html .= $element->getElementHtml();
     $html .= '</span></span>&nbsp;';
     return $html;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:Newchild.php

示例3: render

 public function render(AbstractElement $element)
 {
     $element->addClass('m2epro-fieldset');
     $tooltip = $element->getData('tooltip');
     if (is_null($tooltip)) {
         return parent::render($element);
     }
     $element->addField('help_block_' . $element->getId(), \Ess\M2ePro\Block\Adminhtml\Magento\Form\AbstractForm::HELP_BLOCK, ['content' => $tooltip, 'tooltiped' => true], '^');
     $directionClass = $element->getData('direction_class');
     $element->setLegend($element->getLegend() . $this->getTooltipHtml($tooltip, empty($directionClass) ? 'right' : $directionClass));
     return parent::render($element);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:Fieldset.php

示例4: render

 public function render(AbstractElement $element)
 {
     $isRequired = $element->getData('required');
     if ($isRequired === true) {
         $element->removeClass('required-entry');
         $element->removeClass('_required');
         $element->setClass('M2ePro-required-when-visible ' . $element->getClass());
     }
     $tooltip = $element->getData('tooltip');
     if (is_null($tooltip)) {
         $element->addClass('m2epro-field-without-tooltip');
         return parent::render($element);
     }
     $element->setAfterElementHtml($element->getAfterElementHtml() . $this->getTooltipHtml($tooltip));
     $element->addClass('m2epro-field-with-tooltip');
     return parent::render($element);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:17,代码来源:Element.php

示例5: render

 /**
  * Render element
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  *
  * @see RendererInterface::render()
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $element->addClass('element-value-changer');
     $valueName = $element->getValueName();
     if ($valueName === '') {
         $valueName = '...';
     }
     if ($element->getShowAsText()) {
         $html = ' <input type="hidden" class="hidden" id="' . $element->getHtmlId() . '" name="' . $element->getName() . '" value="' . $element->getValue() . '"/> ' . htmlspecialchars($valueName) . '&nbsp;';
     } else {
         $html = ' <span class="rule-param"' . ($element->getParamId() ? ' id="' . $element->getParamId() . '"' : '') . '>' . '<a href="javascript:void(0)" class="label">';
         if ($this->inlineTranslate->isAllowed()) {
             $html .= $this->escapeHtml($valueName);
         } else {
             $html .= $this->escapeHtml($this->filterManager->truncate($valueName, ['length' => 33, 'etc' => '...']));
         }
         $html .= '</a><span class="element"> ' . $element->getElementHtml();
         if ($element->getExplicitApply()) {
             $html .= ' <a href="javascript:void(0)" class="rule-param-apply"><img src="' . $this->getViewFileUrl('images/rule_component_apply.gif') . '" class="v-middle" alt="' . __('Apply') . '" title="' . __('Apply') . '" /></a> ';
         }
         $html .= '</span></span>&nbsp;';
     }
     return $html;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:32,代码来源:Editable.php

示例6: 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


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