Stop delete action in server-side preRemove

Stop delete action in server-side preRemove

milapmilap Posts: 40Questions: 13Answers: 2
edited January 2016 in Editor

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

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    I would suggest that rather than sending a remove command, you simply have Editor send an edit command that will update your soft removal file. Assuming you have a where 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() and submit().

    Allan

This discussion has been closed.