Hello, How can I set/change the row value in post create event. There is no any example to change

Hello, How can I set/change the row value in post create event. There is no any example to change

Mr Arslan JawedMr Arslan Jawed Posts: 9Questions: 6Answers: 1

Hello,

How can I set/change the row value in post create event. There is no any example to change row data after posting.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,180Questions: 1Answers: 10,411 Site admin

    For context - you also sent me the following by e-mail, which I hope you don't mind me posting here:

    When I try to set value in precreate, there is a foreign Key constraint error. I want to set value after the first table (primary key) data is inserted.

    Can you explain to me your system as a whole here. Why would you want to set a value in post create, when the database should already have the values (they've already been written to the database), so any changes to the values wouldn't be reflected in the database.

    Allan

  • Mr Arslan JawedMr Arslan Jawed Posts: 9Questions: 6Answers: 1
    Answer ✓

    Hello Allan,

    Never mind, I solved it.

    ->on('postCreate', function ($editor,$id, $values, $row ) {
            $editor->db()
            ->query('update', 'address')
            ->set( 'address.customer_id', $values['customer']['customer_id'] )
            ->where('address.id', $id )
            ->exec();
        } )
    
This discussion has been closed.