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   239 Views

Avatar
BenWu

Community Member, 92 Posts

23 August 2014 at 4:54am

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

Forum Moderator, 1132 Posts

25 August 2014 at 8:47pm

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

Community Member, 92 Posts

26 August 2014 at 11:11pm

you are right it works ok.

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

thanks