Form Callback

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.

$form->submitted(function (Form $form) {
    $form->ignore('username');
 });

The form data that is currently submitted can be retrieved from the callback parameter $form:

Get data in model

Can redirect other urls by returning an instance of Symfony\Component\HttpFoundation\Response directly in the callback:

Return error or success information on the page:

deleting & deleted

Two callbacks deleting and deleted were added before and after the deletion.

Can throw an exception directly

Return a json response directly, which can be used to modify the prompt text:

Last updated