Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

addField - adding a date field with date picker
 
Emma86
Sr. Member
 
Total Posts:  110
Joined:  2009-03-03
 

Hi there,

In the function _prepareForm() I’m creating a form i’m using in the admin page on a custome module I have been writing, Im using addField to add text fields however now need to add a date field....

I changed the type from text to date and got an error about missing format .. so added format to the array of properties and guessed at a format and it now doesnt error however a normal text field is displayed.. heres what I have got ...

$fieldset->addField('ends''date', array(
            
'name'      => 'ends',
            
'title'     => Mage::helper('mymod')->__('End Date'),
            
'label'     => Mage::helper('mymod')->__('End Date'),
            
'maxlength' => '50',
          
'format' => 'YYYY-MM-DD',
            
'required'  => true,
        ));

does anyone know how to bring up the date picker for this field instead of a text field? I browsed the php doc for an hour and didnt find a list of options for the addField function.

many thanks all

 
Magento Community Magento Community
Magento Community
Magento Community
 
IcebergCommerce
Sr. Member
 
Avatar
Total Posts:  90
Joined:  2008-06-24
 

Try this:

$fieldset->addField(
    
'ends'
    
'date', array(
        
'label'     => 'End Date',
        
'text'      => $endDateValue,
        
'format'    => 'M/d/yyyy H:mm',
        
'time'      => true,
        
'image'     => $this->getSkinUrl('images/grid-cal.gif'),
        
'required'  => true,
    )
);
 
Magento Community Magento Community
Magento Community
Magento Community
 
IcebergCommerce
Sr. Member
 
Avatar
Total Posts:  90
Joined:  2008-06-24
 

I think you can populate the field with a value by specifying the “value” when adding the field to the form.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top