/** * Render inheritance checkbox (Use Default or Use Website) * * @param \Magento\Framework\Data\Form\Element\AbstractElement $element * @return string */ protected function _renderInheritCheckbox(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $htmlId = $element->getHtmlId(); $namePrefix = preg_replace('#\\[value\\](\\[\\])?$#', '', $element->getName()); $checkedHtml = $element->getInherit() == 1 ? 'checked="checked"' : ''; $html = '<td class="use-default">'; $html .= '<input id="' . $htmlId . '_inherit" name="' . $namePrefix . '[inherit]" type="checkbox" value="1"' . ' class="checkbox config-inherit" ' . $checkedHtml . ' onclick="toggleValueElements(this, Element.previous(this.parentNode))" /> '; $html .= '<label for="' . $htmlId . '_inherit" class="inherit">' . $this->_getInheritCheckboxLabel($element) . '</label>'; $html .= '</td>'; return $html; }
/** * 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); }