preEdit and postEdit
preEdit and postEdit
Hello,
The objective is that I should get a mail at a field change.
I use these functions to check DB before and after edit.
$editor->on( 'preEdit', function ( $editor, $id, $values )
{
logChange2( $editor->db(), 'pre-edit', $id, $values );
} );
$editor->on( 'postEdit', function ( $editor, $id, $values, $row )
{
logChange2( $editor->db(), 'post-edit', $id, $values );
} );
If I check the database row at preEdit and postEdit, they show the same result: both are BEFORE edit. How can I check the final, edited values?
Or do you have a better idea to get which fields are modified with edit?
Thank you and best regards:
Endre, Szak
This discussion has been closed.
Replies
postEdit
should be the one to use. You need to make sure you are using the same database connection though (the$editor->db()
result) since Editor performs its changes in a transaction by default. Can you show me yourlogChange2
function?Allan
Dear Allan,
Sorry for the delay, but I was sick.
I use my own PDO connection within logChange2 function with preEdit and postEdit too.
The goal is that if somebody change a specified field, I have to send a warning email.
So I save the whole row to a different table before and after editing.
Here is my logChange2:
Thank You and best regards:
Endre, Szak
Right - that will do it because Editor's PHP libraries (by default) update the database in a transaction. That's only committed once the events have been completed.
As a quick test for that, add
->transaction( false )
into the Editor chain (before the->process( ... )
method is called.Allan