I follower this tutorial. You can add easily fields as input text or dropdown, but in my case I want to add the magento datepicker.
I have this function :
public function _prepareToRender()
{
$this->addColumn('holiday_name', array(
'label' => Mage::helper('mynamespace_mymodule')->__('Name'),
'style' => 'width:100px',
'renderer' => $this->_getRendererDate(),
));
}
protected function _getRendererDate()
{
if (!$this->_itemRenderer) {
$this->_itemRenderer = $this->getLayout()->createBlock(
'mynamespace_mymodule/config_adminhtml_form_field_holidaydate', '',
array('is_render_to_js_template' => true)
);
}
return $this->_itemRenderer;
}
and this is my block, which extends this class: Mage_Adminhtml_Block_System_Config_Form_Field
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$date = new Varien_Data_Form_Element_Date;
$format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$data = array(
'name' => $element->getName(),
'html_id' => $element->getId(),
'image' => $this->getSkinUrl('images/grid-cal.gif'),
);
$date->setData($data);
$date->setValue($element->getValue(), $format);
$date->setFormat(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
$date->setForm($element->getForm());
return $date->getElementHtml();
}
This is not working, any ideas how can make this work ? thx