Server Side Validation in Orchard CMS Dynamic Forms Module

227 views Asked by At

I need to do some server side validation with some of my forms built using the dynamic forms module. What's the best way to do this? Through workflows?

Specifically, we are getting spam in a customer form and I want to filter out those that include web address in the message field.

1

There are 1 answers

0
matthewjamesr On BEST ANSWER

I ended up adding a Decision to my workflow before the Email action that let me enter C# code into the script field. Here is the code I used in the Decision script field.

var message =  "#{FormSubmission.Field:message}";
if (message.ToLower().Contains("http://") || message.ToLower().Contains("https://")) {
    SetOutcome("Spam"); 
}
else {
    SetOutcome("Real"); 
}

If the message was real, I sent the email. If not, I just end the process.