Date control on a varchar type field

If you wish to give a date control on a “NON” date type field, this code snippet is what you need!

Steps are as below,

Step 1: Create a file under custom/modules/<module_name>/views named view.edit.php Do check if that file already exists under modules/<module_name>/views, if yes, copy over to custom folder and add/edit function display with following code.

global $timedate;
        $cal_dateformat = $timedate->get_cal_date_format();
        $calendar = <<<EOQ
            <script language = "javascript">
            Calendar.setup({
        inputField : "<Your_field_name>", daFormat : "{$cal_dateformat}", ifFormat : "{$cal_dateformat}", showsTime : false, button : "<Your_field_name>", singleClick : true, step : 1
            });
            </script>
EOQ;
        echo $calendar; 

Note :

Change the <Your_field_name> matching with correct field name.
Change the < module_name > matching with correct module name.

Hope you find this blog post helpful.

Feel free to add comments and queries, that helps us to improve the quality of posts.

You can contact us at info@infotechbuddies.com

Thank you.

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *