/** * @return mixed */ public function getAfterElementHtml() { $html = parent::getAfterElementHtml(); /** * getEntityAttribute - use __call */ $addJsObserver = false; if ($attribute = $this->getEntityAttribute()) { if (!($storeId = $attribute->getStoreId())) { $storeId = $this->getForm()->getDataObject()->getStoreId(); } $store = $this->_storeManager->getStore($storeId); $html .= '<strong>' . $this->_localeCurrency->getCurrency($store->getBaseCurrencyCode())->getSymbol() . '</strong>'; if ($this->_taxData->priceIncludesTax($store)) { if ($attribute->getAttributeCode() !== 'cost') { $addJsObserver = true; $html .= ' <strong>[' . __('Inc. Tax') . '<span id="dynamic-tax-' . $attribute->getAttributeCode() . '"></span>]</strong>'; } } } if ($addJsObserver) { $html .= $this->_getTaxObservingCode($attribute); } return $html; }
/** * Disable fields depending on product type * * @return $this */ protected function _disableFields() { if ($this->getDisabled() || $this->_isProductComposite()) { $this->_qty->setDisabled('disabled'); } if (!$this->_isProductComposite() && $this->_qty->getValue() === null) { $this->setDisabled('disabled'); } if ($this->isLocked()) { $this->_qty->lock(); } return $this; }
/** * Render HTML of the element using the rule engine. * * @return string */ public function getInputHtml() { $this->rule->setElementName($this->element->getName()); if ($this->element->getValue()) { /* Hack : reload in a new instance to have element name set. * can not be done in afterLoad of the backend model * since we do not know yet the form structure */ $conditions = $this->element->getValue()->getConditions()->asArray(); $this->rule->getConditions()->loadArray($conditions); $this->element->setRule($this->rule); } $this->input = $this->elementFactory->create('text'); $this->input->setRule($this->rule)->setRenderer($this->conditions); return $this->input->toHtml(); }
/** * Retrieve Element HTML fragment * * @return string */ public function getElementHtml() { $elementDisabled = $this->getDisabled() == 'disabled'; $disabled = false; if (!$this->getValue() || $elementDisabled) { $this->setData('disabled', 'disabled'); $disabled = true; } parent::addClass('validate-number validate-number-range number-range-0.01-1000000000'); $html = parent::getElementHtml(); $htmlId = 'use_config_' . $this->getHtmlId(); $html .= '<br/><input id="' . $htmlId . '" name="use_config[]" value="' . $this->getId() . '"'; $html .= $disabled ? ' checked="checked"' : ''; if ($this->getReadonly() || $elementDisabled) { $html .= ' disabled="disabled"'; } $html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />'; $html .= ' <label for="' . $htmlId . '" class="normal">' . __('Use Config Settings') . '</label>'; $html .= '<script>' . 'require(["prototype"], function(){' . 'toggleValueElements($(\'' . $htmlId . '\'), $(\'' . $htmlId . '\').parentNode);' . '});' . '</script>'; return $html; }
protected function setUp() { $this->ratingOptionCollection = $this->getMock('\\Magento\\Review\\Model\\Resource\\Rating\\Option\\Collection', [], [], '', false); $this->element = $this->getMock('\\Magento\\Framework\\Data\\Form\\Element\\Text', ['setValue', 'setIsChecked'], [], '', false); $this->session = $this->getMock('\\Magento\\Framework\\Session\\Generic', ['getRatingData', 'setRatingData'], [], '', false); $this->rating = $this->getMock('\\Magento\\Review\\Model\\Rating', ['getId', 'getRatingCodes'], [], '', false); $this->optionRating = $this->getMock('\\Magento\\Review\\Model\\Rating\\Option', [], [], '', false); $this->store = $this->getMock('\\Magento\\Store\\Model\\Store', [], [], '', false); $this->form = $this->getMock('\\Magento\\Framework\\Data\\Form', [], [], '', false); $this->directoryReadInterface = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface'); $this->registry = $this->getMock('\\Magento\\Framework\\Registry'); $this->formFactory = $this->getMock('\\Magento\\Framework\\Data\\FormFactory', [], [], '', false); $this->optionFactory = $this->getMock('\\Magento\\Review\\Model\\Rating\\OptionFactory', ['create'], [], '', false); $this->systemStore = $this->getMock('\\Magento\\Store\\Model\\System\\Store', [], [], '', false); $this->viewFileSystem = $this->getMock('\\Magento\\Framework\\View\\FileSystem', [], [], '', false); $this->fileSystem = $this->getMock('\\Magento\\Framework\\Filesystem', ['getDirectoryRead'], [], '', false); $this->rating->expects($this->any())->method('getId')->will($this->returnValue('1')); $this->ratingOptionCollection->expects($this->any())->method('addRatingFilter')->will($this->returnSelf()); $this->ratingOptionCollection->expects($this->any())->method('load')->will($this->returnSelf()); $this->ratingOptionCollection->expects($this->any())->method('getItems')->will($this->returnValue([$this->optionRating])); $this->optionRating->expects($this->any())->method('getResourceCollection')->will($this->returnValue($this->ratingOptionCollection)); $this->store->expects($this->any())->method('getId')->will($this->returnValue('0')); $this->store->expects($this->any())->method('getName')->will($this->returnValue('store_name')); $this->element->expects($this->any())->method('setValue')->will($this->returnSelf()); $this->element->expects($this->any())->method('setIsChecked')->will($this->returnSelf()); $this->form->expects($this->any())->method('setForm')->will($this->returnSelf()); $this->form->expects($this->any())->method('addFieldset')->will($this->returnSelf()); $this->form->expects($this->any())->method('addField')->will($this->returnSelf()); $this->form->expects($this->any())->method('setRenderer')->will($this->returnSelf()); $this->optionFactory->expects($this->any())->method('create')->will($this->returnValue($this->optionRating)); $this->systemStore->expects($this->any())->method('getStoreCollection')->will($this->returnValue(['0' => $this->store])); $this->formFactory->expects($this->any())->method('create')->will($this->returnValue($this->form)); $this->viewFileSystem->expects($this->any())->method('getTemplateFileName')->will($this->returnValue('template_file_name.html')); $this->fileSystem->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($this->directoryReadInterface)); $objectManagerHelper = new ObjectManagerHelper($this); $this->block = $objectManagerHelper->getObject('Magento\\Review\\Block\\Adminhtml\\Rating\\Edit\\Tab\\Form', ['registry' => $this->registry, 'formFactory' => $this->formFactory, 'optionFactory' => $this->optionFactory, 'systemStore' => $this->systemStore, 'session' => $this->session, 'viewFileSystem' => $this->viewFileSystem, 'filesystem' => $this->fileSystem]); }
/** * Set form for both fields * * @param Form $form * @return $this */ public function setForm($form) { $this->weightSwitcher->setForm($form); return parent::setForm($form); }
/** * @return string */ public function getInputHtml() { $this->input = $this->elementFactory->create('text'); $this->input->setRule($this->rule)->setRenderer($this->conditions); return $this->input->toHtml(); }
public function testSetName() { $this->_qtyMock->expects($this->once())->method('setName')->with(self::ATTRIBUTE_NAME . '[qty]'); $this->_block->setName(self::ATTRIBUTE_NAME); }
/** * @covers \Magento\Framework\Data\Form\Element\Text::getHtmlAttributes */ public function testGetHtmlAttributes() { $this->assertEmpty(array_diff(['type', 'title', 'class', 'style', 'onclick', 'onchange', 'onkeyup', 'disabled', 'readonly', 'maxlength', 'tabindex', 'placeholder'], $this->_model->getHtmlAttributes())); }
/** * Set form for both fields * * @param Form $form * @return $this */ public function setForm($form) { $this->_virtual->setForm($form); return parent::setForm($form); }