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.

General Questions

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

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

populateDefaults method on a Page object


4 Posts   1358 Views


30 March 2010 at 10:28pm (Last edited: 30 March 2010 10:28pm), Community Member, 94 Posts

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

1 April 2010 at 12:50pm Community Member, 598 Posts

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


2 April 2010 at 12:49am (Last edited: 2 April 2010 12:59am), Community Member, 271 Posts

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){


2 April 2010 at 3:41am Community Member, 94 Posts

Hey Martijn,

checking on $this->Version worked! thanks