logical deletion

logical deletion

comptabilitatcomptabilitat Posts: 5Questions: 1Answers: 0

Hi,

I want to implement a logical deletion of a record using events on Datatables Editor for PHP.
When clicking delete I want to save '1' in a table field called 'deleted' instead of the physical deletion of the record.

That's my piece of code

public function llistesValors($post) {
        Editor::inst( $this->editorDb, 'llistesValors' )
        ->fields(
            Field::inst( 'id' ),
            Field::inst( 'value' ),
            Field::inst( 'deleted' )
        )
        ->where('dt_deletion',null)
        ->on('preRemove', function($editor,$id,$values) {
            $editor
                ->field('deleted')
                ->setValue(1);
            return true;
        })
        ->process( $post )
        ->json();    
    }

When I click delete button record disappears, but it remains in the database and 'deleted' field hasn't been updated.

Any idea?
Thanks

Carles

Replies

This discussion has been closed.