Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

populateDefaults method on a Page object

Go to End

4 Posts   1793 Views


Community Member, 96 Posts

30 March 2010 at 10:28pm

Edited: 30/03/2010 10:28pm

I'm trying to force populateDefaults method on an extended Page object, but it does not work, is this only working on a

        public function populateDefaults() {

            $this->Title = 'ForcedTitle';


Carbon Crayon

Community Member, 598 Posts

1 April 2010 at 12:50pm

Hi Bartvanirsel,

This function does work on any page class, however the reason it isnt working on the Title field is because I believe there is some JS which runs to set the default page title which would override this.

Try setting another field to see if that works, if it does then obiusly there is some funny stuff going on to generate the default title and you may have to look deeper to override it.

Hope that helps.

Aram - SilverStripe tutorials, tips and other bits


Community Member, 271 Posts

2 April 2010 at 12:49am

Edited: 02/04/2010 12:59am

I can confirm this is not working for Page Titles.

However this does the trick for me:

function populateDefaults() {
		$this->Title = _t('Page.TITLE', "My translated title");
	function onBeforeWrite() {
		if($this->Status == 'New page'){


You could also check by version:

if($this->Version == 0){


Community Member, 96 Posts

2 April 2010 at 3:41am

Hey Martijn,

checking on $this->Version worked! thanks