Magento Background Form element label 2--display Date

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.