本文整理汇总了PHP中Magento\Framework\Data\Form\Element\AbstractElement::setValues方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractElement::setValues方法的具体用法?PHP AbstractElement::setValues怎么用?PHP AbstractElement::setValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Data\Form\Element\AbstractElement
的用法示例。
在下文中一共展示了AbstractElement::setValues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddElementValues
/**
* @param array $initialData
* @param string $expectedValue
* @dataProvider addElementValuesDataProvider
* @covers \Magento\Framework\Data\Form\Element\AbstractElement::addElementValues()
*/
public function testAddElementValues(array $initialData, $expectedValue)
{
$this->_escaperMock->expects($this->any())->method('escapeHtml')->will($this->returnArgument(0));
$this->_model->setValues($initialData['initial_values']);
$this->_model->addElementValues($initialData['add_values'], $initialData['overwrite']);
$this->assertEquals($expectedValue, $this->_model->getValues());
}
示例2: _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();
}
示例3: _applyTypeSpecificConfigCustomer
/**
* Apply configuration specific for different element type
*
* @param string $inputType
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @param AttributeMetadataInterface $attribute
* @return void
*/
protected function _applyTypeSpecificConfigCustomer($inputType, $element, AttributeMetadataInterface $attribute)
{
switch ($inputType) {
case 'select':
$element->setValues($this->_getAttributeOptionsArray($attribute));
break;
case 'multiselect':
$element->setValues($this->_getAttributeOptionsArray($attribute));
$element->setCanBeEmpty(true);
break;
case 'date':
$element->setDateFormat($this->_localeDate->getDateFormatWithLongYear());
break;
case 'multiline':
$element->setLineCount($attribute->getMultilineCount());
break;
default:
break;
}
}
示例4: _applyTypeSpecificConfigCustomer
/**
* Apply configuration specific for different element type
*
* @param string $inputType
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @param \Magento\Customer\Service\V1\Data\Eav\AttributeMetadata $attribute
* @return void
*/
protected function _applyTypeSpecificConfigCustomer($inputType, $element, \Magento\Customer\Service\V1\Data\Eav\AttributeMetadata $attribute)
{
switch ($inputType) {
case 'select':
$element->setValues($this->_getAttributeOptionsArray($attribute));
break;
case 'multiselect':
$element->setValues($this->_getAttributeOptionsArray($attribute));
$element->setCanBeEmpty(true);
break;
case 'date':
$element->setImage($this->getViewFileUrl('images/grid-cal.gif'));
$element->setDateFormat($this->_localeDate->getDateFormatWithLongYear());
break;
case 'multiline':
$element->setLineCount($attribute->getMultilineCount());
break;
default:
break;
}
}
示例5: _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);
}
示例6: _applyTypeSpecificConfig
/**
* Apply configuration specific for different element type
*
* @param string $inputType
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @param \Magento\Eav\Model\Entity\Attribute $attribute
* @return void
*/
protected function _applyTypeSpecificConfig($inputType, $element, \Magento\Eav\Model\Entity\Attribute $attribute)
{
switch ($inputType) {
case 'select':
$element->setValues($attribute->getSource()->getAllOptions(true, true));
break;
case 'multiselect':
$element->setValues($attribute->getSource()->getAllOptions(false, true));
$element->setCanBeEmpty(true);
break;
case 'date':
$element->setDateFormat($this->_localeDate->getDateFormatWithLongYear());
break;
case 'multiline':
$element->setLineCount($attribute->getMultilineCount());
break;
default:
break;
}
}