Example #1
0
 public function render(Varien_Data_Form_Element_Abstract $element)
 {
     $mappingModel = Mage::getModel('orderstatusimport/processor_mapping_fields');
     $mappingModel->setDataPath($this->DATA_PATH);
     $mappingFields = $mappingModel->getMappingFields();
     // Add the actual mapped fields
     $html = '<script>' . "\n";
     $html .= 'var ' . $this->MAPPING_ID . '_mapping_values = new Hash();' . "\n";
     foreach ($mappingModel->getMapping() as $field => $fieldData) {
         $html .= $this->MAPPING_ID . '_mapping_values[\'' . $fieldData['id'] . '\'] = \'' . $this->_escapeStringJs($field) . '\';' . "\n";
     }
     // Add the default values
     $html .= 'var ' . $this->MAPPING_ID . '_default_values = new Hash();' . "\n";
     foreach ($mappingModel->getMapping() as $field => $fieldData) {
         $html .= $this->MAPPING_ID . '_default_values[\'' . $fieldData['id'] . '\'] = \'' . $this->_escapeStringJs($fieldData['default_value']) . '\';' . "\n";
     }
     // Add the possible default values
     $html .= 'var ' . $this->MAPPING_ID . '_possible_default_values = $H({' . "\n";
     $loopLength = 0;
     foreach ($mappingFields as $field => $fieldData) {
         if (isset($fieldData['default_values']) && is_array($fieldData['default_values'])) {
             $loopLength++;
         }
     }
     $loopCounter = 0;
     foreach ($mappingFields as $field => $fieldData) {
         if (isset($fieldData['default_values']) && is_array($fieldData['default_values'])) {
             $loopCounter++;
             $loopLength2 = count($fieldData['default_values']);
             $loopCounter2 = 0;
             $html .= '\'' . $this->_escapeStringJs($field) . '\': {' . "\n";
             foreach ($fieldData['default_values'] as $code => $label) {
                 $loopCounter2++;
                 $html .= '\'' . $this->_escapeStringJs($code) . '\': \'' . $this->_escapeStringJs($label) . '\'';
                 if ($loopCounter2 !== $loopLength2) {
                     $html .= ',';
                 }
                 $html .= "\n";
             }
             $html .= '}';
             if ($loopCounter !== $loopLength) {
                 $html .= ',';
             }
         }
     }
     $html .= '});';
     $html .= '</script>' . "\n";
     $html .= parent::render($element);
     return $html;
 }
 /**
  * Enter description here...
  *
  * @param Varien_Data_Form_Element_Abstract $element
  * @return string
  */
 public function render(Varien_Data_Form_Element_Abstract $element)
 {
     $hint = (array) $element->getFieldConfig()->hint;
     if (!count($hint)) {
         return parent::render($element);
     }
     // Generate Tooltip
     /** @var $tooltip Payone_Core_Block_Adminhtml_System_Config_Tooltip */
     $tooltip = $this->getLayout()->createBlock('payone_core/adminhtml_system_config_tooltip');
     $tooltip->initFormElement($element);
     $tooltipHtml = $tooltip->toHtml();
     $element->setHint('__tooltip_html__');
     $html = parent::render($element);
     $hintToReplace = '<div class="hint" ><div style="display: none;">__tooltip_html__</div></div>';
     $html = str_replace($hintToReplace, $tooltipHtml, $html);
     return $html;
 }