CakeDC / utils

Utils Plugin for CakePHP

Home Page:http://cakedc.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Soft Deletable doesn't work recursively

chrisShick opened this issue · comments

I have tried and tried, but for some reason soft delete does not work recursively. I have dependent set to true in all my model. It will set delete to 1 for the one I clicked to delete, but then doesn't set any of the childrens' delete to 1.

Behavior callbacks run only on the primary model, that's a CakePHP (2.0) framework limitation which is resolved in 3.0. If you want to softdelete 'child' records in relations, he must do it in primary model's beforeDelete() or afterDelete() on your associations and return true.

Hi @burzum, have you're an example of the best way to recursively delete records? I need this to my project.
Fork this repo and add this feature in develop branch, but do not know if it's the best way.

https://github.com/quest/utils/blob/develop/Model/Behavior/SoftDeleteBehavior.php#L176