Adding User that modify a row

Adding User that modify a row

jacklockejacklocke Posts: 3Questions: 1Answers: 0

What is the best way to add some data to an update?
like the user that modify a row.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    Is this using Editor?

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • jacklockejacklocke Posts: 3Questions: 1Answers: 0

    Yes I'm using Editor.

    This is what I wish to do:

    $user = myGetUser();
    
    Field::inst( 'automatic_user' )
        ->setFormatter( Format::ifEmpty($user) );
    

    I want to put in the modify (SQL UPDATE) always the current user.

  • jacklockejacklocke Posts: 3Questions: 1Answers: 0

    ok what I'm looking for was this:

    on the controller for my table:

    ->on( 'preEdit', function ( $editor, $id, $values ) {
            $user= getUser(); // function to get my user
            $editor
                ->field('user')
                ->setValue($user);
    })
    

    Thanks

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    Just to check, is that the solution? :)

    Colin

This discussion has been closed.