Understanding & using Ajax Forms Events

Ajax for Express Forms dispatches 2 events you can use to modify the form's response:

on_before_ajax_express_form_submit triggered right before submitting the form on_ajax_express_form_submit_success right after a successful submission Before a form submission Event: on_before_ajax_express_form_submit

Arguments:

bID the Express form block's ID cID the current page's ID request the request containing all the $_POST values from the form error a boolean set to FALSE indicating that the submission passed validation and there is no error. If there are errors then it is an object of type Concrete\Core\Error\ErrorList\ErrorList You can modify either the request argument or the error argument and return the event.

For instance, you might want to check some of the answers using the "request" argument and send back an ErrorList object through the "error" argument if you found something wrong.

Another possibility is to modify some of the answers in the "request" argument before allowing the submission.

On a successful form submission Event: on_ajax_express_form_submit_success

Arguments:

bID the Express form block's ID cID the current page's ID request the request containing all the $_POST values from the form form the form entity object of type Concrete\Core\Entity\Express\Form success a boolean set to TRUE indicating that the submission was successful message a string containing the message that will be displayed to the user upon submission If you modify the "message" argument and return the event, your modified message will be displayed.

For instance, you could check if the sender is logged in and customize the success message with the user's name.