Greetings
I use custom primary key, named key_id
instead of the id
column.
I use custom function to create this unique key_id, and using setFormatter on the field for that, while in the javascript side, I sent the key_id
as a hidden field with value of null or false, just to make sure it will use the setFormatter function.
Example:
$e = Editor::inst($db, 'customers', 'key_id')
->fields([
Field::inst('customers.key_id')->setFormatter(function ($data) {
if($data){
//Not Modifying the KeyId in case of editting.
return $data;
}else{
//Generating New Id for Newly created Row, which has $data of false or null;
return SomeSpecialFunctionForRandomKeyId();
}
}),
Field::inst('customers.name'),
It is creating it fine, but the problem is, when I listen for the json of the creating request in javascript, I get empty data array. (I'm expecting to get the newly created row in the data array).
When I truned on debug mode for sql queries, I got two of them:
1- One for insertion, which is doing well.
2- Second one for selecting the created row, which bind the value of (ID OF CREATED ROW) to the key_id
primary key column. That's why I get empty array I guess.
Any mistakes in my script or any suggestions ?