Function Description: Today to do a background form element display date time, beginning to think with Magento backstage use of Form element label (1) function, only need to set type types set to date can, but set up, start how also can't get out, and want to load some JS package in the background, Refer to the external JS plug-in to achieve this function, and then consult the company technical cattle, said can directly call the Magento system comes with can, here record how to achieve this function, as follows:
The code below, add the following code in form.php:
$fieldset->addField( 'endtime', 'date',//type类型 array( 'label' => Mage::helper('blog')->__('Endtime'), 'required' => true,//是否为必选项 'name' => 'endtime', 'image' => $this->getSkinUrl('images/grid-cal.gif'),//增加图标 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),//时间格式));
Some additional notes:
1. Sometimes if you want to load some JS in the background form, you can also add in the array (): ' After_element_html ' and '.
2. Add CSS, you can write a good CSS style outside, $style = "width:6px;text-align:center;" Add: ' style ' = + $style,//CSS that defines the button. You can also write directly, for example: ' style ' = ' width:700px; height:500px, '.
$fieldset->addField( 'endtime', 'date',//类型,可以为text,datetime,time,submit,select,radio,checkbox,password,link,label,image,file... array( 'label' => Mage::helper('blog')->__('Endtime'), 'required' => true,//是否为必选项 'style'=> $style,//定义按钮的css . 'name' => 'endtime', 'image' => $this->getSkinUrl('images/grid-cal.gif'),//添加图片 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), 'after_element_html' => ""。 ));
The above describes the Magento background Form element label 2--display date, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.