Using postCreate and postEdit together
Using postCreate and postEdit together
kkuti
Posts: 13Questions: 5Answers: 0
I am able to use both postCreate and postEdit individually successfully. When used together only the postEdit works. I am trying to create table entries of the user and the date when a records are created and when they are edited, when the Add button is used then postCreate is triggered and when the edit button is clicked the postEdit is triggered. The example given works fine because the postEdit only updates one field, in mine I need two fields updated. Please help
This discussion has been closed.
Replies
Hi @kkuti ,
Those events,
postCreate
andpostEdit
, are called after the data has been submitted to the server, so if you want those values stored in the server it would be better to usepreSubmit
.That said, I've set up a test case here and the events are triggering as expected. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.
Cheers,
Colin
Thanx Colin for your prompt reply. I will paste my code and perhaps you can advise me. Code is between the dotted lines
json();">json();" href="#----->json();"> ->json();
What I am trying to achieve here is that the two fields created_by and created_date are populated depending on whether a record is been created or updated.
Please how can I achieve that
Colin thought you were talking about the client-side events. I see from your code above it was actually the server-side PHP events you were considering.
Field->setValue()
won't be useful inpostCreate
orpostEdit
- the write has already taken place to the database, so the change wouldn't make any difference.Why not just put both
setValue
calls into thepre*
event(s)?I'm not quite clear what you want to happen to
created_date
on edit?->set(false)
can be used to not write to it.Allan
Good evening Allan, you have helped me resolve this. It is now working as intended.It was to have two entries created_by and created_date inserted into the table when either a new record was created or an record was edited.