Response hooks
- onResponse()
Called prior to processing the Form submission’s response, which handles actions like downloading a file, displaying a success message, and/or redirecting to another URL.
- Arguments:
response (
object()
) –The response object may have the following defined:
response.download
URL of a file to downloadresponse.redirect
URL to redirect to.response.validationErrors
Array of fields with validation errors.response.errorMessage
String with an error message.response.success
TRUE if the Form was submitted successfully.response.successMessage
String with a success message.
- Returns:
bool|NULL|void Return TRUE to skip the default behavior for handling the response.
MauticFormCallback['formname'] = {
onResponse: function (response) {
// do something custom
},
};
- onResponseStart()
Called prior to the default processing of the response.
- Arguments:
response (
object()
) –The response object may have the following defined:
response.download
URL of a file to downloadresponse.redirect
URL to redirect to.response.validationErrors
Array of fields with validation errors.response.errorMessage
String with an error message.response.success
TRUE if the Form was submitted successfully.response.successMessage
String with a success message.
- Returns:
void
MauticFormCallback['formname'] = {
onResponseStart: function (response) {
// do something custom
},
};
Note
This isn’t called if an onResponse()
hook returns TRUE.
- onResponseEnd()
Called after to the default processing of the response.
- Arguments:
response (
object()
) –The response object may have the following defined:
response.download
URL of a file to downloadresponse.redirect
URL to redirect to.response.validationErrors
Array of fields with validation errors.response.errorMessage
String with an error message.response.success
TRUE if the Form was submitted successfully.response.successMessage
String with a success message.
- Returns:
void
MauticFormCallback['formname'] = {
onResponseEnd: function (response) {
// do something custom
},
};
Note
This isn’t called if an onResponse()
hook returns TRUE or if the page redirects.