php - CakePHP 3 - Use saved data inside afterSave() -
i have submitted form in view processed in controller. happens controller saves edits doing this:
if ($this->requests->save($request)) { // request have been saved. }
now created insert query follow activity of editor aftersave() statement so:
public function aftersave() { // here need data submitted $this->request->save($request)); // how can use data in query? // insert query here. }
i want use aftersave() because want use changes made requests, can't seem find way access posted data.
the documentation says aftersave() contains following parameters:
aftersave(event $event, entityinterface $entity, arrayobject $options)
do need these accomplish want? if so, how use properly? because can't seem debug information see contains of save action.
the question follows:
how can access data saved $this->requests->save($request)
in beforesave() or aftersave() statement use data in query?
how can access data saved $this->requests->save($request) in beforesave() or aftersave() statement use data in query?
the 2nd arg of both callbacks entity data. unless need whole request can data converted marshaller entity 2nd arg $entity
. check documentation on methods:
i don't know problem doing debug($entity);
there show entity data. if not else wrong in code.
just use entity doing whatever want there.
Comments
Post a Comment