Trouble with PHP and Editor w/ 500 errors + cannot manipulate object

Trouble with PHP and Editor w/ 500 errors + cannot manipulate object

actechactech Posts: 2Questions: 1Answers: 0

I would like to manipulate and alter the data being sent through Editor on the server-side. It appears this might be possible through something like within the initialization of Editor like so:
->on( 'preCreate', function ( $e, $id, $values, $row ) {
echo 1;

The ajax php examples provided are very strange. Anytime I attempt to print to a debug output, 500 errors are being thrown without any error messages. Even just trying to work anywhere in the php Editor/ajax file causes 500 errors to be thrown.

What I would really like to understand is where the actual entry point is to work with the data and have access to my other PHP libraries I have built.

I may just be getting confused by the shorthand being used by the code that I am finding quite troubling to use. I'm really not sure and help would be appreciated. I can provide more information as we go along. Below is the ajax php request that both the DataTable and Editor are using ajax for. Without any ->on code, it works and writes back as expected. My actual code has multiple leftjoins that do not write back correctly despite being built as the documentation describes.

I'd really appreciate getting to the point I can use other code to manipulate this object. If I can get that far I can probably figure out what I need to do from there.


 * Example PHP implementation used for the index.html example
require_once($_SERVER['DOCUMENT_ROOT'] .'path/to/file/Id/like/to/include');//This file has static methods I'd like to use.  Any calls to them just fail.
// DataTables PHP library
include( $_SERVER['DOCUMENT_ROOT']. '/php/DataTables.php' );
//At this point any echo/system log print for $_POST['action'] just to even check the action causes 500 error

// Alias Editor classes so they are easy to use

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'table' )
        Field::inst( '' ),
        Field::inst( 'table.first_name' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'table.last_name' )->validator( 'Validate::notEmpty' )
        ->on( 'preCreate', function ( $e, $id, $values, $row ) {
        echo 1;
        error_log("Test");//etc..Doing anything besides what this example initially did just throws 500 errors constantly
    ->process( $_POST )


  • allanallan Posts: 48,908Questions: 1Answers: 7,132 Site admin

    Sounds like you'd need to check the server's error log for details on what is going wrong there. I don't see anything obvious, so I wonder if logging has been disabled? Checking the error log would be the only way to find that out.

    Regarding manipulating the object, you need to have PHP pass by reference - e.g.:

    ->on( 'preCreate', function ( $e, $id, &$values, &$row ) {


  • actechactech Posts: 2Questions: 1Answers: 0

    Logging has not been disabled. I found out what was eating the error message internally. The documentation for Editor had the wrong number of arguments for the function. I resolved the issue after changing the # of arguments to match:

    $editor->on( 'preEdit', function (  $editor, $values ) { }

    Thank you for your answer.

    I ran into another issue after getting that part working. I am using a left join and need the ID from the joined to table in order for editor to work properly. However, the linking ID exists in both the original table and the linked table. I am using preCreate to fill out the main table's ID behind the scenes but I do not want to alter or submit anything regarding the ID in the other table. It seems the create function is always trying to overwrite both IDs and will error if I do not keep them consistent. I can move this over to a new question if necessary.

Sign In or Register to comment.