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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

newClassInstance on CMS change


Go to End


1018 Views

Avatar
zenmonkey

Community Member, 545 Posts

10 December 2013 at 9:26am

I have a page object that has a Enum Field with two slections Sold/For Sale. This field corresponds with a two Page Types MyPage and SoldMyPage. When it's changed I'd like to function much like the Page Type dropdown.

If I call newClassInstance and a write function in onBeforeWrite, won't that cause a loop? In this case since the SoldMyPage is just a direct copy of MyPage, would it be OK to just call change the tyoe using $this->ClassName = SoldMyPage in the onBeforeWrite?