AnsweredAssumed Answered

How to Add Values to the Date Type Field Default Value Dropdown

Question asked by John Boyes on May 14, 2018
Latest reply on Sep 19, 2019 by David Angulo

I have a client that wants a date field to default to 60 days from today.


The current default list in Studio lists: yesterday, today, tomorrow, next week, next monday, next friday, two weeks, next month, first day of next month, three months, six months, next year


I found the TemplateDate class in modules/DynamicFields/templates/Fields/TemplateDate.php file which contains


function __construct() {
     global $app_strings;
     $this->dateStrings = array(
            $app_strings['LBL_YESTERDAY']=> '-1 day',
            $app_strings['LBL_TOMORROW']=>'+1 day',
            $app_strings['LBL_NEXT_WEEK']=> '+1 week',
            $app_strings['LBL_NEXT_MONDAY']=>'next monday',
            $app_strings['LBL_NEXT_FRIDAY']=>'next friday',
            $app_strings['LBL_TWO_WEEKS']=> '+2 weeks',
            $app_strings['LBL_NEXT_MONTH']=> '+1 month',
            $app_strings['LBL_FIRST_DAY_OF_NEXT_MONTH']=> 'first day of next month',
            $app_strings['LBL_THREE_MONTHS']=> '+3 months',  //kbrill Bug #17023
            $app_strings['LBL_SIXMONTHS']=> '+6 months',
            $app_strings['LBL_NEXT_YEAR']=> '+1 year',


If I add

            '60 Days' => '+60 days',

to that list, it shows in Studio however this is not upgrade safe.


So, I created



class CustomTemplateDate extends TemplateDate

function __construct() {

     $this->dateStrings["60 Days"] = '+60 days';





include /custom/modules/DynamicFields/templates/Fields/CustomTemplateDate.php

function get_body(&$ss, $vardef){
     $td = new CustomTemplateDate();
     $ss->assign('default_values', array_flip($td->dateStrings));
     return $ss->fetch('modules/DynamicFields/templates/Fields/Forms/date.tpl');


and custom/include/SugarSmarty/plugins/modifier.default_date_value.php

include /custom/modules/DynamicFields/templates/Fields/CustomTemplateDate.php

function smarty_modifier_default_date_value($defaultValue) {
     global $timedate;
     $td = new CustomTemplateDate();
     return $timedate->asUser(new SugarDateTime($td->dateStrings[$defaultValue]));



However, when I run a Quick Repair and Rebuild, neither the date.php nor the modifier.default_date_value.php files get replaced by their custom versions and Sugar keeps calling the stock files.


What did I do wrong or forget to do?