protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $element->setStyle('display:block')->setName($element->getName() . '[]'); if ($element->getValue()) { $values = explode(',', $element->getValue()); } else { $values = array(); } $payments = Mage::getSingleton('payment/config')->getActiveMethods(); $allowedDefault = array(); $elementsJs = array(); foreach ($payments as $paymentCode => $paymentModel) { $paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title'); $methodsAllowed[$paymentCode] = array('label' => $paymentTitle, 'value' => $paymentCode . "_allow"); array_push($allowedDefault, $paymentCode . "_allow"); $elementsJs[] = $element->getId() . '_' . $paymentCode . ""; } foreach ($payments as $paymentCode => $paymentModel) { $paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title'); $methodsDenied[$paymentCode] = array('label' => $paymentTitle, 'value' => $paymentCode . "_deny"); } if (empty($values)) { $values = $allowedDefault; } $from = $element->setValues($methodsAllowed)->setValue($values)->getElementHtml(); $to = $element->setValues($methodsDenied)->setValue($values)->getElementHtml(); $script = ""; foreach ($elementsJs as $elementj) { $script .= "\n document.getElementById('" . $elementj . "_allow').addEventListener('click', function() {\n if (document.getElementById('" . $elementj . "_deny').checked == true) {\n document.getElementById('" . $elementj . "_deny').checked = false;\n } else {\n document.getElementById('" . $elementj . "_deny').checked = true;\n }\n }, false);\n document.getElementById('" . $elementj . "_deny').addEventListener('click', function() {\n if (document.getElementById('" . $elementj . "_allow').checked == true) {\n document.getElementById('" . $elementj . "_allow').checked = false;\n } else {\n document.getElementById('" . $elementj . "_allow').checked = true;\n\n }\n }, false);\n if (document.getElementById('" . $elementj . "_deny').checked == false && document.getElementById('" . $elementj . "_allow').checked == false) {\n document.getElementById('" . $elementj . "_allow').checked = true;\n }\n "; } return '<div style="white-space: nowrap;"><div style="display:inline-block;padding: 0 5px 0 0; width:50%">' . $from . '</div> <div style="display:inline-block;padding: 0 5px 0 0; width:50%">' . $to . '</div></div><script>' . $script . '</script>'; }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $scope = $element->getScope(); $scope_id = $element->getScopeId(); $inherit = $element->getInherit(); $factoryName = (string) $element->getFieldConfig()->source_model; $sourceModel = Mage::getSingleton($factoryName); $optionArray = $sourceModel->toOptionArray(True, $scope, $scope_id); $element->setValues($optionArray); $html = $this->getElementHtml($element); return $html; // return parent::_getElementHtml($element); }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $_options = array('d' => Mage::helper('adminhtml')->__('Day'), 'm' => Mage::helper('adminhtml')->__('Month'), 'y' => Mage::helper('adminhtml')->__('Year')); $element->setValues($_options)->setClass('select-date')->setName($element->getName() . '[]'); if ($element->getValue()) { $values = explode(',', $element->getValue()); } else { $values = array(); } $_parts = array(); $_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); }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $_options = array('d' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Day'), 'm' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Month'), 'y' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Year')); $element->setValues($_options)->setStyle('width:70px;')->setName($element->getName() . '[]'); if ($element->getValue()) { $values = explode(',', $element->getValue()); } else { $values = array(); } $_parts = array(); $_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(' / ', $_parts); }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $html = ''; $value = explode(',', $element->getValue()); $form = $element->getForm(); $nameprefix = $element->getName(); $element->setValues(array('all' => $this->__('All Days'), 'selected' => $this->__('Selected Days')))->setOnchange('$(\'gomage-delivverydate-specdays\').style.display = (this.value == \'selected\' ? \'block\' : \'none\')')->setName($nameprefix . '[]'); $mode_value = array_shift($value); if (count($value)) { $element->setValue($mode_value); } $html .= $element->getElementHtml(); $element = new Varien_Data_Form_Element_Multiselect(); $element->setForm($form); $element->setId('gomage-delivverydate-specdays'); $element->setClass('select'); $element->setStyle('margin-top:10px;height:160px;' . ($mode_value != 'selected' ? 'display:none;' : '')); $element->setName($nameprefix . '[]'); $element->setValues($this->toOptionArray()); $element->setValue($value); $html .= $element->getElementHtml(); return $html; }
/** * Apply configuration specific for different element type * * @param string $inputType * @param Varien_Data_Form_Element_Abstract $element * @param Mage_Eav_Model_Entity_Attribute $attribute */ protected function _applyTypeSpecificConfig($inputType, $element, Mage_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->setImage($this->getViewFileUrl('images/grid-cal.gif')); $element->setDateFormat(Mage::app()->getLocale()->getDateFormatWithLongYear()); break; case 'multiline': $element->setLineCount($attribute->getMultilineCount()); break; default: break; } }