Sitecore tips and tricks and community news !

Post Top Ad

Post Top Ad

WFFM Custom Error Message


Well known picture, isn't it ? :) Creating our custom message is really helpful in the future: during using our application by end-users or even for other developers who will maintain project.

What in case when we use WFFM, is it possible ? Of course it is, each WFFM action has possibility to display custom error message by dedicated field which looks like:


It works perfectly. We can use many custom actions with own error messages for each other. Generally it solves problem with custom error messages.

But what when someone has a lot of custom error messages or many combination of them? We assume that this person would like to avoid creating many action just to see correct error message. Is there any solution?

Well.. sure it is :) !

Firstly we have to create our custom Form Verification action. It's important to make Form Verification action, not the Save Action.


Secondly we create our custom class which inherits from WffmCheckAction and do the magic inside.
The most important part of this magic for us is to catch exception that can occur. We can for instance put there message we would like to see and re-throw it again. Even in bubble way from previous layers.

At the end this exception message will be displayed above our form.
You don't have to fill error message fields in the action. The code you have written is everything you need.

Cheers !

No comments:

Post a Comment