21293 Posts in 5733 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » Automatically insert current date into date field of new pages
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1059 Views |
-
Automatically insert current date into date field of new pages

28 July 2010 at 12:47pm
I use the following code in conjunction with the legacydatetimefields module to allow the administrator to select a date:
$fields->addFieldToTab("Root.Content.Times", new PopupDateTimeField('RankingDate', 'Ranking Date'));
When a page is create that field is blank. I want the current date to be placed in that field when new pages are created but after the page is created I want the administrator to be able to change it to any date.
-
Re: Automatically insert current date into date field of new pages

28 July 2010 at 7:24pm Last edited: 28 July 2010 7:25pm
public function populateDefaults(){
$this->RankingDate = date("Y-m-d");
}
| 1059 Views | ||
|
Page:
1
|
Go to Top |


