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


PHP AbstractElement::getId方法代碼示例

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


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

示例1: testIsCollapseState

 /**
  * @param mixed $expanded
  * @param int $expected
  * @dataProvider isCollapseStateDataProvider
  */
 public function testIsCollapseState($expanded, $expected)
 {
     $this->_user->setExtra(['configState' => []]);
     $this->_element->setGroup(isset($expanded) ? ['expanded' => $expanded] : []);
     $html = $this->_model->render($this->_element);
     $this->assertContains('<input id="' . $this->_element->getHtmlId() . '-state" name="config_state[' . $this->_element->getId() . ']" type="hidden" value="' . $expected . '" />', $html);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:12,代碼來源:GroupTest.php

示例2: _isCollapseState

 /**
  * Return collapse state
  *
  * @param AbstractElement $element
  * @return string|true
  */
 protected function _isCollapseState($element)
 {
     $extra = $this->_authSession->getUser()->getExtra();
     if (isset($extra['configState'][$element->getId()])) {
         return $extra['configState'][$element->getId()];
     }
     return true;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:14,代碼來源:Expanded.php

示例3: _isCollapseState

 /**
  * Return collapse state
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return bool
  */
 protected function _isCollapseState($element)
 {
     $extra = $this->_authSession->getUser()->getExtra();
     if (isset($extra['configState'][$element->getId()])) {
         return $extra['configState'][$element->getId()];
     }
     $groupConfig = $element->getGroup();
     if (!empty($groupConfig['expanded'])) {
         return true;
     }
     return false;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:18,代碼來源:Group.php

示例4: addElement

 /**
  * Add form element
  *
  * @param AbstractElement $element
  * @param bool $after
  * @return Form
  */
 public function addElement(AbstractElement $element, $after = false)
 {
     if ($this->getForm()) {
         $this->getForm()->checkElementId($element->getId());
         $this->getForm()->addElementToCollection($element);
     }
     parent::addElement($element, $after);
     return $this;
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:16,代碼來源:AbstractElement.php

示例5: prepareElementHtml

 /**
  * Prepare chooser element HTML
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element Form Element
  * @return \Magento\Framework\Data\Form\Element\AbstractElement
  */
 public function prepareElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $uniqId = $this->mathRandom->getUniqueHash($element->getId());
     $sourceUrl = $this->getUrl('cms/page_widget/chooser', ['uniq_id' => $uniqId]);
     $chooser = $this->getLayout()->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->setElement($element)->setConfig($this->getConfig())->setFieldsetId($this->getFieldsetId())->setSourceUrl($sourceUrl)->setUniqId($uniqId);
     if ($element->getValue()) {
         $page = $this->_pageFactory->create()->load((int) $element->getValue());
         if ($page->getId()) {
             $chooser->setLabel($this->escapeHtml($page->getTitle()));
         }
     }
     $element->setData('after_element_html', $chooser->toHtml());
     return $element;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:20,代碼來源:Chooser.php

示例6: prepareElementHtml

 /**
  * Prepare chooser element HTML
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element Form Element
  * @return \Magento\Framework\Data\Form\Element\AbstractElement
  */
 public function prepareElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $uniqId = $this->mathRandom->getUniqueHash($element->getId());
     $sourceUrl = $this->getUrl('sales_rule/promo_quote/chooser', array('uniq_id' => $uniqId));
     $chooser = $this->getLayout()->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->setElement($element)->setConfig($this->getConfig())->setFieldsetId($this->getFieldsetId())->setSourceUrl($sourceUrl)->setUniqId($uniqId);
     if ($element->getValue()) {
         $rule = $this->ruleFactory->create()->load((int) $element->getValue());
         if ($rule->getId()) {
             $chooser->setLabel($rule->getName());
         }
     }
     $element->setData('after_element_html', $chooser->toHtml());
     return $element;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:20,代碼來源:Chooser.php

示例7: prepareElementHtml

 /**
  * Prepare chooser element HTML
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element Form Element
  * @return \Magento\Framework\Data\Form\Element\AbstractElement
  */
 public function prepareElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $uniqId = $this->mathRandom->getUniqueHash($element->getId());
     $sourceUrl = $this->getUrl('catalog/category_widget/chooser', ['uniq_id' => $uniqId, 'use_massaction' => false]);
     $chooser = $this->getLayout()->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->setElement($element)->setConfig($this->getConfig())->setFieldsetId($this->getFieldsetId())->setSourceUrl($sourceUrl)->setUniqId($uniqId);
     if ($element->getValue()) {
         $value = explode('/', $element->getValue());
         $categoryId = false;
         if (isset($value[0]) && isset($value[1]) && $value[0] == 'category') {
             $categoryId = $value[1];
         }
         if ($categoryId) {
             $label = $this->_categoryFactory->create()->load($categoryId)->getName();
             $chooser->setLabel($label);
         }
     }
     $element->setData('after_element_html', $chooser->toHtml());
     return $element;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:25,代碼來源:Chooser.php

示例8: prepareElementHtml

 /**
  * Prepare chooser element HTML
  *
  * @param AbstractElement $element Form Element
  * @return AbstractElement
  */
 public function prepareElementHtml(AbstractElement $element)
 {
     $uniqId = $this->mathRandom->getUniqueHash($element->getId());
     $sourceUrl = $this->getUrl('catalog/product_widget/chooser', ['uniq_id' => $uniqId, 'use_massaction' => false]);
     $chooser = $this->getLayout()->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->setElement($element)->setConfig($this->getConfig())->setFieldsetId($this->getFieldsetId())->setSourceUrl($sourceUrl)->setUniqId($uniqId);
     if ($element->getValue()) {
         $value = explode('/', $element->getValue());
         $productId = false;
         if (isset($value[0]) && isset($value[1]) && $value[0] == 'product') {
             $productId = $value[1];
         }
         $categoryId = isset($value[2]) ? $value[2] : false;
         $label = '';
         if ($categoryId) {
             $label = $this->_resourceCategory->getAttributeRawValue($categoryId, 'name', $this->_storeManager->getStore()) . '/';
         }
         if ($productId) {
             $label .= $this->_resourceProduct->getAttributeRawValue($productId, 'name', $this->_storeManager->getStore());
         }
         $chooser->setLabel($label);
     }
     $element->setData('after_element_html', $chooser->toHtml());
     return $element;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:30,代碼來源:Chooser.php

示例9: _addAdditionalFormElementData

 /**
  * Add additional data to form element
  *
  * @param AbstractElement $element
  * @return $this
  */
 protected function _addAdditionalFormElementData(AbstractElement $element)
 {
     switch ($element->getId()) {
         case 'email':
             $element->setRequired(0);
             $element->setClass('validate-email');
             break;
     }
     return $this;
 }
開發者ID:zhangjiachao,項目名稱:magento2,代碼行數:16,代碼來源:Account.php

示例10: addElementToCollection

 /**
  * @param AbstractElement $element
  * @return $this
  */
 public function addElementToCollection($element)
 {
     $this->_elementsIndex[$element->getId()] = $element;
     $this->_allElements->add($element);
     return $this;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:10,代碼來源:Form.php

示例11: _addAdditionalFormElementData

 /**
  * Add additional data to form element
  *
  * @param AbstractElement $element
  * @return $this
  */
 protected function _addAdditionalFormElementData(AbstractElement $element)
 {
     if ($element->getId() == 'region_id') {
         $element->setNoDisplay(true);
     }
     return $this;
 }
開發者ID:zhangjiachao,項目名稱:magento2,代碼行數:13,代碼來源:Address.php

示例12: _getAdditionalElementHtml

    /**
     * Custom additional element html
     *
     * @param AbstractElement $element
     * @return string
     */
    protected function _getAdditionalElementHtml($element)
    {
        // Add name attribute to checkboxes that correspond to multiselect elements
        $nameAttributeHtml = $element->getExtType() === 'multiple' ? 'name="' . $element->getId() . '_checkbox"' : '';
        $elementId = $element->getId();
        $checkboxLabel = __('Change');
        $html = <<<HTML
<span class="attribute-change-checkbox">
    <label>
        <input type="checkbox" {$nameAttributeHtml} onclick="toogleFieldEditMode(this, '{$elementId}')" />
        {$checkboxLabel}
    </label>
</span>
<script>initDisableFields("{$elementId}")</script>
HTML;
        if ($elementId === 'weight') {
            $html .= <<<HTML
<script>jQuery(function(\$) {
    \$('#weight_and_type_switcher, label[for=weight_and_type_switcher]').hide();
});</script>
HTML;
        }
        return $html;
    }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:30,代碼來源:Attributes.php

示例13: _isCollapseState

 /**
  * Collapsed or expanded fieldset when page loaded?
  *
  * @param AbstractElement $element
  * @return bool
  */
 protected function _isCollapseState($element)
 {
     if ($element->getExpanded() || $element->getForm() && $element->getForm()->getElements()->count() === 1) {
         return true;
     }
     $extra = $this->_authSession->getUser()->getExtra();
     if (isset($extra['configState'][$element->getId()])) {
         return $extra['configState'][$element->getId()];
     }
     return $this->isCollapsedDefault;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:17,代碼來源:Fieldset.php

示例14: _getAdditionalElementHtml

    /**
     * Custom additional element html
     *
     * @param AbstractElement $element
     * @return string
     */
    protected function _getAdditionalElementHtml($element)
    {
        // Add name attribute to checkboxes that correspond to multiselect elements
        $nameAttributeHtml = $element->getExtType() === 'multiple' ? 'name="' . $element->getId() . '_checkbox"' : '';
        $elementId = $element->getId();
        $dataAttribute = "data-disable='{$elementId}'";
        $dataCheckboxName = "toggle_" . "{$elementId}";
        $checkboxLabel = __('Change');
        $html = <<<HTML
<span class="attribute-change-checkbox">
    <input type="checkbox" id="{$dataCheckboxName}" name="{$dataCheckboxName}" class="checkbox" {$nameAttributeHtml} onclick="toogleFieldEditMode(this, '{$elementId}')" {$dataAttribute} />
    <label class="label" for="{$dataCheckboxName}">
        {$checkboxLabel}
    </label>
</span>
HTML;
        if ($elementId === 'weight') {
            $html .= <<<HTML
<script>require(['Magento_Catalog/js/product/weight-handler'], function (weightHandle) {
    weightHandle.hideWeightSwitcher();
});</script>
HTML;
        }
        return $html;
    }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:31,代碼來源:Attributes.php

示例15: _getAdditionalElementHtml

    /**
     * Custom additional element html
     *
     * @param AbstractElement $element
     * @return string
     */
    protected function _getAdditionalElementHtml($element)
    {
        // Add name attribute to checkboxes that correspond to multiselect elements
        $nameAttributeHtml = $element->getExtType() === 'multiple' ? 'name="' . $element->getId() . '_checkbox"' : '';
        $elementId = $element->getId();
        $dataAttribute = "data-disable='{$elementId}'";
        $dataCheckboxName = "toggle_" . "{$elementId}";
        $checkboxLabel = __('Change');
        $html = <<<HTML
<span class="attribute-change-checkbox">
    <input type="checkbox" id="{$dataCheckboxName}" name="{$dataCheckboxName}" class="checkbox" {$nameAttributeHtml} onclick="toogleFieldEditMode(this, '{$elementId}')" {$dataAttribute} />
    <label class="label" for="{$dataCheckboxName}">
        {$checkboxLabel}
    </label>
</span>
HTML;
        if ($elementId === 'weight') {
            $html .= <<<HTML
<script type="text/javascript">require(["jquery"],function(\$) {
    \$('#weight_and_type_switcher, label[for=weight_and_type_switcher]').hide();
});</script>
HTML;
        }
        return $html;
    }
開發者ID:aiesh,項目名稱:magento2,代碼行數:31,代碼來源:Attributes.php


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