stack: Error: Primary key element is not available in the data set

stack: Error: Primary key element is not available in the data set

ChrisLChrisL Posts: 12Questions: 3Answers: 0
edited June 4 in Editor

I'm using the registered version of Datatables/Editor widely on a new site.

I've found what might be a bug thought.

Im accessing a table with 3 columns:

id which is an auto increment primary key
name with is just a string - I forget the exact length
number which is just an integer.

I create the Datatables instance using all three fields but I set the 'id' field to be hidden using columnDefs because the value is only there so when a row is selected I can pick up the 'id' for further use.

I create the editor object with all three fields but again for the same reason I set the 'id' field to hidden.

In the node.js controller the 'id' field is listed with


If I don't mention the ID field in the node.js controller, Datatables falls down because it can't populate the hidden column.

When I do mention the field and click the 'New' button and fill out the values and click 'Save' I get the following error message:

stack: Error: Primary key element is not available in the data set
    at Editor.pkeyToValue (/var/www/html/
    at Editor._pkeySubmitMerge (/var/www/html/
    at Editor.<anonymous> (/var/www/html/
    at step (/var/www/html/
    at (/var/www/html/
    at fulfilled (/var/www/html/

yet the record is correctly created., but Editor seems to stall with its little progress bar cycling.

From logging it appears as expected since the row is created that it does an SQL insert setting all three fields, but setting the ID field to null and hence it gets an auto increment value as planned.

How do I stop this error stalling something that is otherwise functioning as intended as far as I can see?

Thanks in advance!


  • allanallan Posts: 54,909Questions: 1Answers: 8,606 Site admin


    Just to confirm, you have a Field instance for the primary key? If so, and it is auto-increment, you'll want to do:


    (change id as needed) as Editor will handle the primary key value for you automatically. The only reason to have a Field::inst('id') is if you want to show the primary key value in the table or the form.


Sign In or Register to comment.