本文整理汇总了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;
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例8: testGetEscapedValueWithFilter
/**
* @covers \Magento\Framework\Data\Form\Element\AbstractElement::getEscapedValue()
*/
public function testGetEscapedValueWithFilter()
{
$value = '<a href="#hash_tag">my \'quoted\' string</a>';
$expectedValue = '<a href="#hash_tag">my \'quoted\' string</a>';
$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());
}
示例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>";
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}