Is it possible to add server side validation on form submit?

We do need the ability to do a validation of the whole submitted form, and be able to inform the user if validation fails. Is there a way to do this?

The best I could come up with is:

BizFormItemEvents.Insert.Before += BizFormItem_CancelOnFail;

But when this will end up in a silent fail, because from there it is not possible to inform the user on fail.

The idea behind is that we want to submit the data to an external system, and when that fails we want to give feedback the submission failed. Saving to the database will be canceled in BizFormItemEvents.Insert.Before

This means no data is stored in Kentico (safe), and based on FormSettings the form will either act as default Kentico, or submit to the external system.


Environment

  • Xperience by Kentico version: [31.4.0]
Tags:
Form Builder

Answers

The BizFormItemEvents.Insert.Before occurs at the Provider level (the database layer). By the time the code gets here The Action has already received the post, The Form Widget has already validated its own internal state, The "UI" part of the process is essentially over; this is just the "Data" part.

Instead, define a custom validation rule.

Register it with the [assembly: RegisterFormValidationRule(...)]

Apply that rule to one of the fields in the Form Builder UI.

If the validation depends on multiple fields at once you will need to create a custom form component.

To response this discussion, you have to login first.