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.

Data Model Questions /

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

Setting a Default ParentID

Go to End

3 Posts   1064 Views


Community Member, 545 Posts

25 November 2012 at 1:25pm

I was wondering if its possible to set the ParentID of a pagetype to specific page. The pagetype is being controlled by a ModelAdmin instead of the pages interface. I've tryed setting the $defaults array in the __construct() but I get a class does not exist error

       static $defaults;	

	 * Static methods
	 * ----------------------------------*/
	public function __construct() {
		$mainListingPage = SiteTree::get_by_link("listings");
		$this->defaults = array(
			"ParentID" => $mainListingPage->ID,

Should I just handle it in the onBeforeWrite ?


Forum Moderator, 5523 Posts

2 December 2012 at 5:42pm

Use onBeforeWrite().


Community Member, 545 Posts

11 December 2012 at 3:52am

Calling it in onBefore write was failing I ended up adding a hidden ParentID field to the form and setting the value with the function. When I have a chance I'll try onBeforeWrite again so I can trackdown the actual issue.