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, Ed, biapar, Willr, Ingo, swaiba

Inherit data from parent?

Go to End

2 Posts   958 Views


Community Member, 52 Posts

14 March 2009 at 7:30am

Let's say I have a Page (Page class) called Susan. On this page is a tab called 'Favorites' and on that tab, is a text field called 'Favorite song'.

What I want to achieve, is that when a subpage is created under Susan, say page 'Donna', Donna inherits Her parents favorite song but can later change this.


Carbon Crayon

Community Member, 598 Posts

14 March 2009 at 10:02am

Edited: 14/03/2009 10:03am

Hi Rob

If you are using 2.3 then you can use the onAfterWrite() function in your page model. Something like this should work:

function onAfterWrite() {
$this->FavouriteSong = $this->Parent()->FavouriteSong;