Issue with DataTables Editor PHP Library After Migrating to Composer

Problem:
I’m having an issue with DataTables Editor PHP after migrating from a 3rd-party library to using Composer. Everything was working fine when I was using the old 3rd-party library, but after switching to Composer, I can see the data in the table, but when trying to add data, the data comes back empty.
Old Code (With 3rd-Party Library):

When using the older version of DataTables Editor (version 1.4.2), the following setup worked correctly:


<?php

include( "../3rdParty/DataTables-1.10.7/extensions/Editor-PHP-1.4.2/php/DataTables.php" );
use
    DataTablesEditor,
    DataTablesEditorField,
    DataTablesEditorFormat,
    DataTablesEditorJoin,
    DataTablesEditorValidate;

$klantendata = Editor::inst( $db, 'KlantenGroep' )
    ->pkey( 'id' )
    ->field(
        Field::inst( 'KlantenGroep.name' ),
        Field::inst( 'KlantenGroep.mobielehelptekst' )
    );

    $data = $klantendata->process($_POST)
    ->data();

echo json_encode( $data );

Explanation:

  • I was using an older version of DataTables Editor PHP (1.4.2), and this code worked perfectly for displaying and adding data to the KlantenGroep table.
  • The database connection was managed using a custom DatabaseConfig class and passed into DataTablesDatabase.

New Code (With Composer Package):

After migrating to Composer and installing “datatables.net/editor-php”: “^2.3”, I updated the code to reflect the new setup:

<?php

require_once '../bootstrap.php';
require_once '../db_config.php';

$sql_details = DatabaseConfig::getDetails();
$db = new DataTablesDatabase($sql_details);

use
    DataTablesEditor,
    DataTablesEditorField,
    DataTablesEditorFormat,
    DataTablesEditorJoin,
    DataTablesEditorValidate;

$klantendata = Editor::inst($db, 'KlantenGroep')
    ->pkey('id')
    ->field(
        Field::inst('KlantenGroep.name'),
        Field::inst('KlantenGroep.mobielehelptekst')
    );

$data = $klantendata->process($_POST)
    ->data();

echo json_encode($data);

Current Issue:

  • Library Version: “datatables.net/editor-php”: “^2.3”
  • Problem: Data is successfully displayed in the table, but when trying to add or edit data, the data comes back empty in the response.
  • Error: There’s no specific error message, but no data is being added or updated.

Question:

Why is the data being returned empty when adding or editing, despite using the same logic that worked in the previous version with the 3rd-party library? Could this be an issue with the new version of the DataTables Editor PHP library, or am I missing something in my code migration?

Any guidance or suggestions on how to resolve this issue would be greatly appreciated!

Steps I’ve Tried:

  • Verified the PDO connection works correctly by executing manual queries.
  • Verified that $_POST contains the expected data by dumping it.
  • Ensured the structure and syntax of the new code match what is required by the new version.