model-form currently has three methods for receiving callback functions:
// callback after form submission$form->submitted(function (Form $form) {//...});// callback before save$form->saving(function (Form $form) {//...});// callback after save$form->saved(function (Form $form) {//...});
If required, you can add additional fields to ignore using the submitted function e.g.
useIlluminate\Support\MessageBag;// redirect back with an error message$form->saving(function ($form) { $error =newMessageBag(['title'=>'title...','message'=>'message....', ]);returnback()->with(compact('error'));});// redirect back with a successful message$form->saving(function ($form) { $success =newMessageBag(['title'=>'title...','message'=>'message....', ]);returnback()->with(compact('success'));});
deleting & deleted
Two callbacks deleting and deleted were added before and after the deletion.