Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Getting Mollom to work on custom form class

Go to End

4 Posts   1940 Views

Samba Sam

Community Member, 85 Posts

11 March 2010 at 5:50am

Edited: 14/03/2010 7:40am

Right now, I am not getting any captcha on my custom form. I would greatly appreciate it if someone could check my SpamProtectorManager method in my ContactForm.php code below to see if it is correct. I've asked for help in the Forms forum with this but haven't gotten any responses as of yet.
Thanks for the help,

PS: The is an abridged edited version of my previous post "Testing Mollom".


class ContactForm extends Form {
   function __construct($controller, $name) {
       $Params = Director::urlParams();
       $fields = new FieldSet(
		    new TextField('Name', 'Name*'),
			new EmailField('Email', 'Email*'),
			new TextareaField('Comments','Comments*'));
        $actions = new FieldSet(
            new FormAction("SendContactForm", "Submit"));
       $requiredFields = new RequiredFields('Name', 'Email', 'Comments');
	$form = new Form($this, '__construct', $fields, $actions,$requiredFields);
	$protector = SpamProtectorManager::update_form($form, 'Captcha');
	if($protector) $protector->setFieldMapping('Name', 'Email','Comments');
        // protector method based on example at
        parent::__construct($controller, $name, $fields, $actions,$requiredFields);
   } // END __construct
   function forTemplate() {
      return $this->renderWith(array(


Community Member, 323 Posts

11 March 2010 at 10:05am


Don’t forget that the captcha does not appear if you’re logged-in as admin.

Hope it helps,

Samba Sam

Community Member, 85 Posts

11 March 2010 at 11:12am

Edited: 14/03/2010 7:33am

Thanks for your response. Yes, I had tested my form while being logged out of admin - still no captcha.


Samba Sam

Community Member, 85 Posts

14 March 2010 at 7:34am

Does any one have any other suggestions (e.g., code edits)