/** * Create renderer used for displaying the country select element * * @return Mage_Core_Block_Html_Select */ protected function _getTemplateRenderer() { if (!$this->_templateRenderer) { $this->_templateRenderer = $this->getLayout()->createBlock('dhlonlineretoure/adminhtml_form_field_country_select', '', array('is_render_to_js_template' => true)); /* @var $sourceModel Mage_Adminhtml_Model_System_Config_Source_Country */ $sourceModel = Mage::getModel('adminhtml/system_config_source_country'); $this->_templateRenderer->setOptions($sourceModel->toOptionArray()); } return $this->_templateRenderer; }
/** * Select field filter HTML with selected value. * * @param Mage_Eav_Model_Entity_Attribute $attribute * @param mixed $value * @return string */ protected function _getSelectHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value) { if ($attribute->getFilterOptions()) { $options = array(); foreach ($attribute->getFilterOptions() as $value => $label) { $options[] = array('value' => $value, 'label' => $label); } } else { $options = $attribute->getSource()->getAllOptions(false); } if ($size = count($options)) { // add empty vaue option $firstOption = reset($options); if ('' === $firstOption['value']) { $options[key($options)]['label'] = ''; } else { array_unshift($options, array('value' => '', 'label' => '')); } $selectBlock = new Mage_Core_Block_Html_Select(array('name' => $this->getFilterElementName($attribute->getAttributeCode()), 'id' => $this->getFilterElementId($attribute->getAttributeCode()), 'class' => 'select', 'extra_params' => 'style="width:280px"')); return $selectBlock->setOptions($options)->setValue($value)->getHtml(); } else { return $this->_helper->__('Attribute does not has options, so filtering is impossible'); } }