Does standalone (inline) solution supports table with 2 primary keys?

Does standalone (inline) solution supports table with 2 primary keys?

marwal2marwal2 Posts: 6Questions: 3Answers: 0

Error messages shown: Primary key data doesn't match submitted data

I would like to ask, if anyone knows the correct setup for standalone form that uses DB table with 2 primary keys?
I have implemented a one with inline edition. I used compound DB primary key, because of 2 primary keys.

Editor::inst( $db, 'firma', array('id','id_projektu'))
    ->fields(
        Field::inst( 'id' )->set(false),
        Field::inst( 'id_projektu' )->set(false),
                ...

My HTML form starts with the following:

<div data-editor-id="row_<?php echo $_SESSION['id'];?>">

So for example data-editor-id, during run-time, is set to row_1, which is fine for single primary key (tested; works fine).
With a such setup I am receiving "Primary key data doesn't match submitted data" error.
I suspect that it's because of incorrect value in data-editor-id.
Should it be constructed from both keys? If yes, then how?

I would like to mention that debug info is empty in a such case ...

Thank you for answer.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin
    Answer ✓

    You are correct - the id used on the client-side needs to be a combination of the two values, but more than that, we also use a hash of the primary key name’s to make sure there isn’t any data corruption if the code is changed and the client-side not refreshed for the update.

    This is the code that is responsible for doing that combination.

    That said, is your id column not unique? If so, that would be enough to address each row individually.

    Allan

  • marwal2marwal2 Posts: 6Questions: 3Answers: 0

    After code adjustment everything works as expected.
    Allan, thank you your answer!

This discussion has been closed.