Understanding & using Ajax Forms Events

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

  1. on_before_ajax_express_form_submit triggered right before submitting the form
  2. on_ajax_express_form_submit_success right after a successful submission

Before a form submission



  1. bID the Express form block's ID
  2. cID the current page's ID
  3. request the request containing all the $_POST values from the form
  4. 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



  1. bID the Express form block's ID
  2. cID the current page's ID
  3. request the request containing all the $_POST values from the form
  4. form the form entity object of type Concrete\Core\Entity\Express\Form
  5. success a boolean set to TRUE indicating that the submission was successful
  6. 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.