events (row ID) and non-default primary key name (id)
events (row ID) and non-default primary key name (id)
Consider this example:
->on( 'postEdit', function ( $editor, $id, &$values, &$row ) {
logChange( $editor->db(), 'edit', $id, $values );
} )
the $id
is described in the documentation as:
$id - ID of the row that has been edited
However, if I don't use the default id
name, like:
$editor = Editor::inst( $db, 'staff', 'staffid' );
the $id
is always empty; and my workaround is:
->on( 'postEdit', function ( $editor, $id, &$values, &$row ) {
logChange( $editor->db(), 'edit', $values['staffid'], $values );
} )
my question, why the $id
is always empty, is this expected?
This question has an accepted answers - jump to answer
Answers
No not at all. Can show me your full PHP controller there please? Also, what version of the Editor PHP libraries are you using?
Thanks,
Allan
Hi Allan,
thanks for your time. it appears that my problem was a bug in my code, I found out when I was preparing the full code.
Sorry for the inconvenience and thanks again.
Hi we0038,
Please, can you explain to us what the problem was?
I have the same problem (empty id in postCreate)
Thank you
That post was back in April - we'll probably need to look at your own issue afresh. Perhaps you can post the controller code you are using?
Allan