5

enter image description here

app/code/local/Companyname/Deliverydate/Block/Adminhtml/Mappingdate.php

<?php

class Companyname_Deliverydate_Block_Adminhtml_Mappingdate  
    extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
{

    public function __construct()
    {
        $helper = Mage::helper('deliverydate');
        $dateFormat = Mage::app()->getLocale()- 
        >getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
        $this->addColumn( 'date', array(
          'name'   => 'date',
          'label'  => $helper->__('Date'),
          'image'  => $this->getSkinUrl('images/grid-cal.gif'),
          'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
          'value' => date('d/m/Y'),
          'format'       => $dateFormat
     )); 

        parent::__construct();
    }
}

system.xml

<?xml version="1.0"?>
<config>
    <tabs>
        <bootsgrid translate="label" module="deliverydate">
            <label>Bootsgrid</label>
            <sort_order>400</sort_order>
        </bootsgrid>
    </tabs>
    <sections>
        <deliverydate translate="label" module="deliverydate">
            <class>separator-top</class>
            <label>Delivery Date</label>
            <tab>bootsgrid</tab>
            <sort_order>130</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <deliverydate_general translate="label">
                    <label>General</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>10</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <enabled translate="label">
                            <label>Enabled</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment>Select Yes to enable this feature.</comment>
                        </enabled>
                        <!-- <on_which_page translate="label">
                            <label>Show on?</label>
                            <frontend_type>select</frontend_type>
                            <source_model>Bootsgrid_Deliverydate_Model_Config_Option</source_model>
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment>Choose at which step delivery date should be captured.</comment>
                        </on_which_page> -->
<!--                         <deliverydate_html translate="label">
                            <label>Design HTML</label>
                            <frontend_type>textarea</frontend_type>
                            <sort_order>3</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment></comment>
                        </deliverydate_html>
 -->                        <deliverydate_format>
                            <label>Date Format</label>
                            <frontend_type>select</frontend_type>
                            <source_model>Bootsgrid_Deliverydate_Model_Config_Dateformat</source_model>
                            <sort_order>4</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment>Choose date format in which date will be displayed in frontend and admin panel.</comment>
                        </deliverydate_format>
                        <!-- <deliverytime_format>
                            <label>Time Format</label>
                            <frontend_type>select</frontend_type>
                            <source_model>Bootsgrid_Deliverydate_Model_Config_Timeformat</source_model>
                            <sort_order>4</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment>Choose time format in which time will be displayed in frontend and admin panel.</comment>
                        </deliverytime_format> -->
                        <deliverydate_dayoff>
                            <label>Day Off</label>
                            <frontend_type>multiselect</frontend_type>
                            <source_model>Bootsgrid_Deliverydate_Model_Config_Dayoff</source_model>
                            <sort_order>5</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment>Choose days on which shipping will not be available.</comment>
                        </deliverydate_dayoff>
                        <mapping_date>
                            <label>Date Off</label>
                            <frontend_model>deliverydate/adminhtml_mappingdate</frontend_model>
                            <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>   <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </mapping_date>
                    </fields>
                </deliverydate_general>
            </groups>
        </deliverydate>
    </sections>
</config>

Refered this

enter image description here

4
  • Try following solution magecomp.com/blog/… Please let me know still issue not fixed.
    – user55548
    Commented Mar 9, 2019 at 12:15
  • I was tried an above link output came normal input date - prnt.sc/mw51sc but i need a datepicker with serialized array Commented Mar 11, 2019 at 5:12
  • you can check here dropdown field add here you are using Mage_Core_Block_Html_Date Commented Mar 11, 2019 at 5:19
  • I will try and update you -@rakesh Commented Mar 11, 2019 at 5:24

1 Answer 1

1

To add date & time picker, first of all you need to create date.php file at following location in your custom extension

[Vendor][ModuleName]\ Block\Adminhtml\System\Config

<?php
class [Vendor]\[ModuleName]\ Block\Adminhtml\System\Config \date extends Mage_Adminhtml_Block_System_Config_Form_Field
{
                protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
    {
        $date = new Varien_Data_Form_Element_Date;
        $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);

        $data = array(
            'name'      => $element->getName(),
            'html_id'   => $element->getId(),
            'image'     => $this->getSkinUrl('images/grid-cal.gif'),
        );
        $date->setData($data);
        $date->setValue($element->getValue(), $format);
        $date->setFormat(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM));
        $date->setClass($element->getFieldConfig()->validate->asArray());
        $date->setForm($element->getForm());

        return $date->getElementHtml();
    }
}
?>

Once you have created date.php file, you have to add below code in System.xml file.

<startdate translate="label">
<label>Offer Start Date</label>
<frontend_model>notificationbar/adminhtml_system_config_date</frontend_model>
<backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
<sort_order>150</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</startdate>
<starttime translate="label comment">
<label>Offer Start Time</label>
 <frontend_type>time</frontend_type>
<sort_order>152</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
 <show_in_store>1</show_in_store>
</starttime>
5
  • your answer is support for normal datepicker but i need a date picker within serialized array Commented Mar 11, 2019 at 4:25
  • Define <backend_model>adminhtml/system_config_backend_serialized_array</backend_model> in system.xml file Commented Mar 11, 2019 at 6:31
  • adminhtml/system_config_backend_serialized_array is use as serialized array. Commented Mar 11, 2019 at 6:31
  • check updated answer Commented Mar 11, 2019 at 6:32
  • I already tried that way its reflects output prnt.sc/mw5rcj - @Ronak Commented Mar 11, 2019 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.