Stop delete action in server-side preRemove
Stop delete action in server-side preRemove
Hello,
Is there any way to stop deletion by catching server-side preRemove event and change it to something else?
->on( 'preRemove', function ( $editor, $id, $values ) {
//kill DELETE action and make UPDATE instead
} )
I am looking for soft delete solution.
The one that I have found on forum is great: https://datatables.net/forums/discussion/31310/possible-to-soft-delete
but the problem with it is that it changes remove to edit action and I've got some custom sql()
in
->on( 'postEdit', function ( $editor, $id, $values, $row ) {
$editor->db()->sql('CUSTOM QUERY BASED ON $row DATA');
})
so in that case I receive sql errors (because some fields are empty). Of course I can make some if's that search for empty data so code could assume that this is not a real edit but soft-deletion but maybe there is a nicer way?
This question has an accepted answers - jump to answer
Answers
I would suggest that rather than sending a
remove
command, you simply have Editor send anedit
command that will update your soft removal file. Assuming you have awhere
condition on the Editor instance, then it won't be read back and it will be removed from the client-side.This is the documentation for how to create a custom button, which you can use to call
edit()
,set()
andsubmit()
.Allan