events (row ID) and non-default primary key name (id)

events (row ID) and non-default primary key name (id)

we0038we0038 Posts: 39Questions: 13Answers: 1

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

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

    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

  • we0038we0038 Posts: 39Questions: 13Answers: 1

    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.

  • Pere BruguerasPere Brugueras Posts: 2Questions: 0Answers: 0

    Hi we0038,
    Please, can you explain to us what the problem was?
    I have the same problem (empty id in postCreate)
    Thank you

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    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

Sign In or Register to comment.