Step-1 Add the following code in app/code/local/YourNamespace/YourModule/Block/Adminhtml/Yourmodule/Edit/Tab/Form.php
$fieldset->addField('purchase_date', 'date', array(
'label' => Mage::helper('subscription')->__('Purchase Date'),
'name' => 'purchase_date',
'image' => $this->getSkinUrl('images/grid-cal.gif'),
'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
));
Step-2 Now the date field with a datepicker is displayed in your admin form. To save the value into database, you need to add a line of code in saveAction() function of app/code/local/YourNamespace/YourModule/controllers/YourModuleController.php
if ($data = $this->getRequest()->getPost()) {
$data = $this->_filterDates($data, array('purchase_date', 'expiry_date'));
$model = Mage::getModel('subscription/subscription');
$model->setData($data)
->setId($this->getRequest()->getParam('id'));
Hope it helps. Thanks.
$fieldset->addField('purchase_date', 'date', array(
'label' => Mage::helper('subscription')->__('Purchase Date'),
'name' => 'purchase_date',
'image' => $this->getSkinUrl('images/grid-cal.gif'),
'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
));
Step-2 Now the date field with a datepicker is displayed in your admin form. To save the value into database, you need to add a line of code in saveAction() function of app/code/local/YourNamespace/YourModule/controllers/YourModuleController.php
if ($data = $this->getRequest()->getPost()) {
$data = $this->_filterDates($data, array('purchase_date', 'expiry_date'));
$model = Mage::getModel('subscription/subscription');
$model->setData($data)
->setId($this->getRequest()->getParam('id'));
Hope it helps. Thanks.
No comments:
Post a Comment