Home

Forms

Adding Fields to Page Comments


Submitted by Dan Rye

This isn't as simple as it should be.  I am also sure that things could be done in a better way, please comment if you have improvements.

Override PageComments

You'll need to override the ContentController->PageComments() function.  This is essentially a copy and paste from sapphire/core/control/ContentController.php and change the reference to PageCommentInterface to PageCommentExtendedInterface, which you will create in the next step.

Read More >>

Using jQuery for form validation

As you may have noticed, SilverStripes built in form validation is based on Prototype and is pretty limited. It also means that even though you might be using jQuery for other things on your site, you will still need to load prototype.js and all the accociated files that SilverStripe requires for it's built in JavaScript form validation.

However, using a jQuery validator, such as the excellent Validate plugin has some obvious benefits:

  1. Validate multiple forms on a single page
  2. Customize error messages
  3. More control over inline error styling
  4. Remove the need for loading extra JS files, such as Prototype.js and Behavior.js etc. (more than 90KB in total)
  5. Extended validation options as well as the ability to create custom regex validation rules.

So now that you are (most likely) convinced about the benefits of using jQuery validation let's get started.

Read More >>

Creating a Simple Contact Form

In this tutorial we create a simple contact form which sends an email using a custom template. This type of form can be extended to create complex sets of fields and processing actions.

Read More >>