I am trying to display time chooser in magento date picker but it didn't how up.
can anyone please guide on this how to set timer in magento system confif.
I have followed This Link but it show only date picker.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI am trying to display time chooser in magento date picker but it didn't how up.
can anyone please guide on this how to set timer in magento system confif.
I have followed This Link but it show only date picker.
You need to make changes in the _getElementHtml() function.
Please replace the _getElementHtml() function with below code:
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$date = new Varien_Data_Form_Element_Datetime;
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$data = array(
'name' => $element->getName(),
'html_id' => $element->getId(),
'image' => $this->getSkinUrl('images/grid-cal.gif'),
);
$date->setTime(true); // added this new line of code
$date->setData($data);
$date->setValue($element->getValue(), $format);
$date->setFormat(Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
$date->setClass($element->getFieldConfig()->validate->asArray());
$date->setForm($element->getForm());
return $date->getElementHtml();
}
I have made changes in 3 places:
Step 1:
$date = new Varien_Data_Form_Element_Date;
to
$date = new Varien_Data_Form_Element_Datetime;
Step 2:
$format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
to
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
Step 3:
$date->setFormat(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
to
$date->setFormat(Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
and
Step 4:
$date->setTime(true); // added this new line of code
$date = new Varien_Data_Form_Element_Date;
when i use $date = new Varien_Data_Form_Element_Datetime;
it gives error like Fatal error: Class 'Varien_Data_Form_Element_Datetime' not found
because there is no file like Datetime in Element folder.
– Pradip Garchar
Nov 22 '17 at 8:06