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 /

onBeforeDelete issues SS3


Reply


3 Posts   505 Views

Avatar
zenmonkey

Community Member, 528 Posts

21 December 2012 at 3:17am

I have a Page Type that automoatically creates a folder to save any images loaded to it. I've set up an onBeforeDelete to delete the folder if the page is deleted, however it throws an excpetion that I'm trying to delete an an Object without an ID. I'm sure its in the onBeforeDelete becaise if I remove it the page deletes fine.

   function onBeforeDelete() {
   
      if($this->FolderID != 0){
         $folder = $this->Folder();
         
         if($folder) {
            $folder->delete();   
         }
      }
      parent::onBeforeDelete();
   }

Any ideas?

Avatar
zenmonkey

Community Member, 528 Posts

18 January 2013 at 5:19am

Bump! Still haven't figured this out. the $folder->delete() throws an error that i'm trying to delete a dataobject without an ID

Avatar
zenmonkey

Community Member, 528 Posts

18 January 2013 at 5:45am

After some digging I've realized onBeforeWrite fires on Unpublish, so the Dataobejct is deleted then and not when the page is deleted