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

OnBeforeDelete in DataExtension - What's it for?


Reply

3 Posts   155 Views

Avatar
BenWu

23 August 2014 at 4:54am Community Member, 90 Posts

When I use DataExtension to add $has_many pdf files, I want to use OnBeforeDelete within the DataExtension subclass to remove those files before the deletion of the data object itself. But it seems not working.

To get around, I have to add codes into the data object's own class, which is not very ideal because the class doesn't have codes mentioning the pdf files.

Is this a limitation of the DataExtension of do i miss something?

thanks!!

Avatar
martimiz

25 August 2014 at 8:47pm Forum Moderator, 1091 Posts

onBeforeDelete() should work if your DataExtension extends the DataObject that is deleted. To have an idea what's wrong we'd need a to have a look at the code...

Avatar
BenWu

26 August 2014 at 11:11pm Community Member, 90 Posts

you are right it works ok.

Like other functions, i need to use $this->owner->Images() to remove images

thanks