Best Way to Implement Custom Contact Form with Validation in SilverStripe 5?

Hi everyone,

I’m currently working on a project using SilverStripe 5, and I need to implement a custom contact form with proper validation and email functionality.

My requirements are:

  • Custom form fields (Name, Email, Phone, Message)

  • Server-side validation

  • Spam protection (preferably honeypot or reCAPTCHA)

  • Sending confirmation email to user

  • Sending notification email to admin

  • Clean template integration

I understand that SilverStripe provides Form, FormAction, and validation classes, but I’d like to follow best practices for SilverStripe 5 specifically.

Here are a few questions:

  1. What is the recommended way to structure a custom form in SS5 — inside a PageController or as a separate Form class?

  2. What’s the best method for spam protection in SilverStripe 5?

  3. Is there a preferred approach for handling email templates?

  4. Any recommended modules for better form handling?

If anyone has a clean example or best practice workflow, I’d really appreciate it.

Thanks in advance!

A good place to start is the Silverstripe userforms module (GitHub - silverstripe/silverstripe-userforms: UserForms module provides a visual form builder for the Silverstripe CMS. No coding required to build forms such as contact pages.)

It allows for creation of forms with all kinds of fields, can handle notifications and will automatically work with the spam protection module. (GitHub - silverstripe/silverstripe-spamprotection: Spam protection module for Silverstripe CMS)

As for the ‘best’ spam protection, that’s going to get you a lot of opinions! Google recaptcha is what it is, and generally works OK. I’ve found Cloudflare Turnstile to be very good. These are all available in the spamprotection system.