Reputation: 89
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());
}
Upvotes: 3
Views: 5568
Reputation: 9281
You can create a widget with xtype "datetime" and apply the value as "now", in order to initialize the date field with today's date in case the author hasn't selected any.
An example widget is shown below :
"date":{"fieldLabel":"datetime","xtype":"datetime","name":"./date","value":"now","jcr:primaryType":"cq:Widget"}
This would work for Pageproperties as well.
Upvotes: 3