/** * @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()); }
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(); }
/** * 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; } }
/** * 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; } }
/** * @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); }
/** * 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; } }
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $element->setValue((int) $this->moduleHelper->getConfig()->getGroupValue('/component/amazon/', 'mode')); $element->setValues([['label' => __('Disabled'), 'value' => '0'], ['label' => __('Enabled'), 'value' => '1']]); return $element->getElementHtml(); }