How to add in updated by field with user login id in inline Editor?

How to add in updated by field with user login id in inline Editor?

wonglikwonglik Posts: 44Questions: 5Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • wonglikwonglik Posts: 44Questions: 5Answers: 0

    Can show me how I can add 'updated by' with user id when any data table record updated?

  • allanallan Posts: 63,916Questions: 1Answers: 10,535 Site admin

    If you are using our server-side libraries for Editor, then I would suggest you use a server-side event. That is how to modified fields for PHP, the .NET and Node.js docs have similar sections.

    Allan

  • wonglikwonglik Posts: 44Questions: 5Answers: 0
    edited January 20

    I have already modify as below

                    Field::inst( 'recorddate' )->set( false ),
                    Field::inst( 'lastupdatedate' )->set( false ),
                    Field::inst( 'lastupdateby' )->set( Field:: SET_EDIT )
            )
            ->on( 'preCreate', function ( $editor, &$values ) {
            $editor
                ->field( 'lastupdateby' )
                ->setValue( $_SESSION['username'] );
        } )
        ->on( 'preEdit', function ( $editor, $id, &$values ) {
            $editor
                ->field( 'lastupdateby' )
                ->setValue( $_SESSION['username'] );
        } )
            ->process( $_POST )
            ->json();
    

    But it came up with 'A system error has occurred (More information).' when updating a record. What have I done wrong?

  • allanallan Posts: 63,916Questions: 1Answers: 10,535 Site admin

    What is the response from the server? The "system error" message indicates that invalid JSON has been returned by the server - hopefully it will include an error message stating what the issue is. You could also check the PHP error log which will have a warning or error message in it.

    Allan

  • wonglikwonglik Posts: 44Questions: 5Answers: 0

    I have checked all the log file but can't find any one related.

  • allanallan Posts: 63,916Questions: 1Answers: 10,535 Site admin

    What does the server return in that case? You can see it in the network request in your browser's developer tools. Or if you are having problems with it, drop me a link and I'll take a look.

    Allan

Sign In or Register to comment.