1 Reply Latest reply on Jan 9, 2013 11:23 AM by rush_pawan

    how can i set todays date as default date for a date field in page properties

    efish11 Level 1

      i have a date field(creation date) in page properties, which i want to default to todays date.

       

      How i can accomplish this, i am using a listener on render event

       

      even though i can read the value back, i cannot see to see the date set in page properties.

       

      seems to me i am missing something basic

       

      function(dateField) {

       

      console.log("in render");

      var todaysDate=new Date().format('m/d/Y');

      console.log(todaysDate);

      dateField.setValue(todaysDate);

      CQ.Ext.getCmp("dateCreated").setValue(todaysDate);

      console.log( CQ.Ext.getCmp("dateCreated").getValue());

             

      }

        • 1. Re: how can i set todays date as default date for a date field in page properties
          rush_pawan Level 4

          Hi,

           

          Actually i did not debug much in detail why it is not working with "render" event but suspecting when you modify any property in render event the value for property has already been set and modification is not affected as its rendering time.

           

          I created a new listner on "beforeloadcontent" content event and its working correctly because this event allows you to modify the property value as its before load. Please use below on "beforeloadcontent" event.

           

          function(field, record, path) {

          alert("in render");

          var todaysDate=new Date().format('m/d/Y');

          this.setValue(todaysDate);

          return false;      

          }

           

          Let me know if you face any issue.

           

          Thanks,

          Pawan