Silverstripe ajax form module

Installs: 2 256

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 5

Forks: 1

Open Issues: 0


1.0.1 2018-02-23 13:53 UTC

This package is auto-updated.

Last update: 2024-06-06 23:56:12 UTC



Ajax forms for silverstripe, using jquery and jquery validate


  • SilverStripe CMS ^4.0
  • jQuery
  • jQuery validate


composer require "thewebmen/silverstripe-ajaxforms"

How to use

Make sure you have jquery and jquery validate loaded on your pages with ajax forms. Also include the following js file:


Then create a form by extending the class TheWebmen\Ajaxforms\AjaxForm that returns an instance of the TheWebmen\Ajaxforms\AjaxFormResponse class on success.

Form example

use TheWebmen\Ajaxforms\AjaxForm;
use SilverStripe\Control\RequestHandler;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\RequiredFields;

class ExampleForm extends AjaxForm {

    public function __construct(RequestHandler $controller = null)
        $fields = new FieldList(array(
            TextField::create('MyField', 'This is a field')

        $actions = new FieldList(array(
           FormAction::create('handle', 'Send')

        $validator = new ExampleFormValidator(array(

        parent::__construct($controller, 'MyField', $fields, $actions, $validator);

    public function handle($data){
        $response = new \TheWebmen\Ajaxforms\AjaxFormResponse();
        return $response->redirect('');


class ExampleFormValidator extends RequiredFields {

    public function php($data)
        $valid = parent::php($data);
        if($data['MyField'] != 'Test'){
                'This field is only valid if the value is: Test',
            $valid = false;
        return $valid;


Form errors are displayed using jQuery validate, you can initiate your own jQuery validate to customize the settings or you can let the ajaxforms.js script handle this to use jQuery validate's default settings.

The class ".is-posting" is added to the form while it is positing, you should use this class to add some progress styling.


  • Improve documentation
  • Add check if page exist for the redirectToPage response