Example #1
0
 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $html = parent::_getElementHtml($element);
     $js = '<script type="text/javascript">
            var updater = new RegionUpdater("tax_defaults_country", "none", "tax_defaults_region", %s, "nullify");
            if(updater.lastCountryId) {
                var tmpRegionId = $("tax_defaults_region").value;
                var tmpCountryId = updater.lastCountryId;
                updater.lastCountryId=false;
                updater.update();
                updater.lastCountryId = tmpCountryId;
                $("tax_defaults_region").value = tmpRegionId;
            } else {
                updater.update();
            }
            </script>';
     $html .= sprintf($js, $this->_directoryHelper->getRegionJson());
     return $html;
 }
Example #2
0
 /**
  * Retrieve Element HTML fragment
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     return parent::_getElementHtml($element) . $this->_toHtml();
 }
Example #3
0
 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $html = parent::_getElementHtml($element);
     $html .= "<script type=\"text/javascript\">var updater = new RegionUpdater('tax_defaults_country'," . " 'tax_region', 'tax_defaults_region', " . $this->_directoryHelper->getRegionJson() . ", 'disable');</script>";
     return $html;
 }
Example #4
0
 /**
  * Get country selector html
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $urlParams = ['section' => $this->getRequest()->getParam('section'), 'website' => $this->getRequest()->getParam('website'), 'store' => $this->getRequest()->getParam('store'), StructurePlugin::REQUEST_PARAM_COUNTRY => '__country__'];
     $urlString = $this->_escaper->escapeJsQuote($this->_url->getUrl('*/*/*', $urlParams));
     $jsString = '
         $("' . $element->getHtmlId() . '").observe("change", function () {
             location.href = \'' . $urlString . '\'.replace("__country__", this.value);
         });
     ';
     if ($this->_defaultCountry) {
         $urlParams[self::REQUEST_PARAM_DEFAULT_COUNTRY] = '__default__';
         $urlString = $this->_escaper->escapeJsQuote($this->_url->getUrl('*/*/*', $urlParams));
         $jsParentCountry = $this->_escaper->escapeJsQuote($this->_defaultCountry);
         $jsString .= '
             $("' . $element->getHtmlId() . '_inherit").observe("click", function () {
                 if (this.checked) {
                     location.href = \'' . $urlString . '\'.replace("__country__", \'' . $jsParentCountry . '\')
                         .replace("__default__", "1");
                 }
             });
         ';
     }
     return parent::_getElementHtml($element) . $this->_jsHelper->getScript('document.observe("dom:loaded", function() {' . $jsString . '});');
 }