#StackBounty: #magento-1.7 #admin #magento-1 #adminhtml #adminform Admin datetime picker returning empty array on post

Bounty: 50

I have a custom admin edit form with the following fields:

$dateTimeFormatIso = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$fieldsetRefInfo->addField('start_date', 'date', array(
    'name' => 'start_date',
    'input_format' => Varien_Date::DATETIME_INTERNAL_FORMAT,
    'format' => $dateTimeFormatIso,
    'time' => true,
    'image' => $this->getSkinUrl('images/grid-cal.gif'),
    'required' => true,
    'label' => Mage::helper('vendor_module')->__('Start Date'),
    'title' => Mage::helper('vendor_module')->__('Start Date'),
    'style' => 'width: 120px',
));
$fieldsetRefInfo->addField('expire_date', 'date', array(
    'name' => 'expire_date',
    'input_format' => Varien_Date::DATETIME_INTERNAL_FORMAT,
    'format' => $dateTimeFormatIso,
    'time' => true,
    'image' => $this->getSkinUrl('images/grid-cal.gif'),
    'required' => true,
    'label' => Mage::helper('vendor_module')->__('Expiration Date'),
    'title' => Mage::helper('vendor_module')->__('Expiration Date'),
    'style' => 'width: 120px',
));

When I get the data back in my controller upon save, the start_date field comes back as string, but the expire_date field comes back as an array with no values:

$data['start_date'] = '3/5/18 5:46 PM';
$data['expire_date'] = ['from' => '', 'to' => '', 'local' => 'en_US'];

I’m assuming there’s some JS going on in the background that is transforming the data, since the $_POST data comes back the same way.

Any ideas as to where I can start looking for this data transformation?


Get this bounty!!!

Leave a Reply