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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

OnBeforeDelete in DataExtension - What's it for?


Go to End


3 Posts   1269 Views

Avatar
BenWu

Community Member, 97 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, 1391 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, 97 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