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


PHP AbstractElement::setValue方法代碼示例

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


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

示例1: _getElementHtml

 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $element->setStyle('width:70px;')->setName($element->getName() . '[]');
     if ($element->getValue()) {
         $values = explode(',', $element->getValue());
     } else {
         $values = [];
     }
     $from = $element->setValue(isset($values[0]) ? $values[0] : null)->getElementHtml();
     $to = $element->setValue(isset($values[1]) ? $values[1] : null)->getElementHtml();
     return __('<label class="label"><span>from</span></label>') . $from . __('<label class="label"><span>to</span></label>') . $to;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:16,代碼來源:YearRange.php

示例2: _getElementHtml

 /**
  * @param AbstractElement $element
  * @return string
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $_options = ['d' => __('Day'), 'm' => __('Month'), 'y' => __('Year')];
     $element->setValues($_options)->setClass('select-date')->setName($element->getName() . '[]');
     if ($element->getValue()) {
         $values = explode(',', $element->getValue());
     } else {
         $values = [];
     }
     $_parts = [];
     $_parts[] = $element->setValue(isset($values[0]) ? $values[0] : null)->getElementHtml();
     $_parts[] = $element->setValue(isset($values[1]) ? $values[1] : null)->getElementHtml();
     $_parts[] = $element->setValue(isset($values[2]) ? $values[2] : null)->getElementHtml();
     return implode(' <span>/</span> ', $_parts);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:20,代碼來源:DateFieldsOrder.php

示例3: _getElementHtml

 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $extensionVersion = $this->_helper->getExtensionVersion();
     $versionLabel = sprintf('<a href="%s" title="Easy Template Path Hints for Magento 2" target="_blank">%s</a>', self::EXTENSION_URL, $extensionVersion);
     $element->setValue($versionLabel);
     return $element->getValue();
 }
開發者ID:EliasKotlyar,項目名稱:magento2-easy-template-path-hints,代碼行數:11,代碼來源:Version.php

示例4: render

    public function render(AbstractElement $element)
    {
        $element->unsScope();
        $element->unsCanUseWebsiteValue();
        $element->unsCanUseDefaultValue();
        $element->setValue(__('Update'));
        $element->setData('onclick', 'javascript:geoIpUpdate(); return false;');
        $element->setData('class', 'action-default');
        $element->setData('after_element_js', '<script type="application/javascript">
    require(["jquery"], function($){
        window.geoIpUpdate = function() {
            $.getJSON(
                "' . $this->getUrl('tobai_geoip2/database/update') . '",
                function(data) {
                    if (data.status_info) {
                        $("#row_tobai_geoip2_database_status .value").html(data.status_info);
                    }
                }
            );
        };

        $(document).bind("ajaxSend", function() {
            $("body").trigger("processStart");
        });

        $(document).bind("ajaxComplete", function() {
            $("body").trigger("processStop");
        });
    });
</script>');
        return parent::render($element);
    }
開發者ID:ytorbyk,項目名稱:magento2-geo-ip2,代碼行數:32,代碼來源:Update.php

示例5: _getElementHtml

 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $element->setValue(0);
     $element->setDisabled('disabled');
     $element->setValues([['label' => __('Disabled - Coming Soon...'), 'value' => '0']]);
     return $element->getElementHtml();
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:7,代碼來源:Field.php

示例6: render

 /**
  * Render given element (return html of element)
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element The element
  *
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     if ($this->getValues()) {
         $element->setValue($this->getValues());
     }
     $this->setElement($element);
     return $this->toHtml();
 }
開發者ID:smile-sa,項目名稱:elasticsuite,代碼行數:15,代碼來源:AbstractRenderer.php

示例7: _getElementHtml

 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $extensionVersion = $this->_helper->getExtensionVersion();
     $extensionTitle = 'Custom Shipping';
     $versionLabel = sprintf('<a href="%s" title="%s" target="_blank">%s</a>', self::EXTENSION_URL, $extensionTitle, $extensionVersion);
     $element->setValue($versionLabel);
     return $element->getValue();
 }
開發者ID:MagePsycho,項目名稱:magento2-custom-shipping,代碼行數:12,代碼來源:Version.php

示例8: testGetEscapedValueWithFilter

 /**
  * @covers \Magento\Framework\Data\Form\Element\AbstractElement::getEscapedValue()
  */
 public function testGetEscapedValueWithFilter()
 {
     $value = '<a href="#hash_tag">my \'quoted\' string</a>';
     $expectedValue = '&lt;a href=&quot;#hash_tag&quot;&gt;my \'quoted\' string&lt;/a&gt;';
     $filterMock = $this->getMock('Magento\\Framework\\Object', ['filter'], [], '', false);
     $filterMock->expects($this->once())->method('filter')->with($value)->will($this->returnArgument(0));
     $this->_model->setValueFilter($filterMock);
     $this->_model->setValue($value);
     $this->assertEquals($expectedValue, $this->_model->getEscapedValue());
 }
開發者ID:,項目名稱:,代碼行數:13,代碼來源:

示例9: getElementHtml

 public function getElementHtml(AbstractElement $element)
 {
     $classes = ["tinify-connection-status"];
     switch ($this->status->getStatus()) {
         case ConnectionStatus::UNKNOWN:
             $element->setValue(__("Save configuration to check status."));
             break;
         case ConnectionStatus::SUCCESS:
             $classes[] = "tinify-success";
             $element->setValue(__("API connection successful."));
             $element->setComment(__("You have made %1 compressions this month.", $this->status->getCompressionCount()));
             break;
         case ConnectionStatus::FAILURE:
             $classes[] = "tinify-failure";
             $element->setValue(__("API connection unsuccessful."));
             $element->setComment(__("Error: %1", $this->status->getLastError()));
             break;
     }
     return "<div class=\"" . implode(" ", $classes) . "\">{$element->getElementHtml()}</div>";
 }
開發者ID:tinify,項目名稱:magento2-plugin,代碼行數:20,代碼來源:ConnectionStatusField.php

示例10: render

 /**
  * Render country field considering request parameter
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $country = $this->getRequest()->getParam(StructurePlugin::REQUEST_PARAM_COUNTRY);
     if ($country) {
         $element->setValue($country);
     }
     if ($element->getCanUseDefaultValue()) {
         $this->_defaultCountry = $this->_scopeConfig->getValue(self::FIELD_CONFIG_PATH);
         if (!$this->_defaultCountry) {
             $this->_defaultCountry = $this->directoryHelper->getDefaultCountry();
         }
         if ($country) {
             $shouldInherit = $country == $this->_defaultCountry && $this->getRequest()->getParam(self::REQUEST_PARAM_DEFAULT_COUNTRY);
             $element->setInherit($shouldInherit);
         }
         if ($element->getInherit()) {
             $this->_defaultCountry = null;
         }
     }
     return parent::render($element);
 }
開發者ID:IlyaGluschenko,項目名稱:protection,代碼行數:27,代碼來源:Country.php

示例11: _getElementHtml

 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $element->setValue($this->_cache->load('admin_notifications_lastcheck'));
     $format = $this->_localeDate->getDateTimeFormat(\IntlDateFormatter::MEDIUM);
     return $this->dateTimeFormatter->formatObject($this->_localeDate->date(intval($element->getValue())), $format);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:10,代碼來源:Notification.php

示例12: _getElementHtml

 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $element->setValue($this->_cache->load('admin_notifications_lastcheck'));
     $format = $this->_localeDate->getDateTimeFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM);
     return $this->_localeDate->date(intval($element->getValue()))->toString($format);
 }
開發者ID:,項目名稱:,代碼行數:10,代碼來源:

示例13: _getElementHtml

 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $element->setValue($this->_cache->load(\Dotdigitalgroup\Email\Helper\Config::CONNECTOR_FEED_LAST_CHECK_TIME));
     $format = $this->_localeDate->getDateTimeFormat(\IntlDateFormatter::MEDIUM);
     return $this->dateTimeFormatter->formatObject($this->_localeDate->date(intval($element->getValue())), $format);
 }
開發者ID:dragonsword007008,項目名稱:magento2,代碼行數:6,代碼來源:Notification.php


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