User defined forms compulsory / required checkbox

I've been playing around with SilverStripe's User defined forms module recently. For one of the forms I wanted the user to have to check a checkbox before they can continue. You know the ones that say: 'I agree to the above terms and conditions'.

First I tried adding a checkbox and making it required, this however didn't work as it submitted without being checked. I then briefly looked into the code to see whether there is an easy way of creating new input type, before noticing the 'Checkbox group' field.

The 'Checkbox group' field provides a ready made solution.

  • Create a checkbox group
  • Add a single option to the group (click Show Options first)
  • Check Valdiation: Is this field Required?
  • Add 'Custom Error Message' to avoid displaying of EditableCheckboxGroupField12 is required.
  • If you only want a checkbox with a line of text to agree to enter a space for the label, otherwise something like EditableCheckboxGroupField12 will be shown.