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.

All other Modules /

Discuss all other Modules here.

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

Getting Mollom to work on custom form class


Reply


4 Posts   1413 Views

Avatar
Samba Sam

Community Member, 85 Posts

11 March 2010 at 5:50am

Edited: 14/03/2010 7:40am

Hi,
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,
Sam

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

<?php

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 http://svn.silverstripe.com/open/modules/mollom/trunk/INSTALL
   
parent::__construct($controller, $name, $fields, $actions,$requiredFields);
} // END __construct

function forTemplate() {
return $this->renderWith(array(
$this->class,
'Form'
));
}
}
?>

Avatar
Juanitou

Community Member, 323 Posts

11 March 2010 at 10:05am

Hi!

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

Hope it helps,
Juan

Avatar
Samba Sam

Community Member, 85 Posts

11 March 2010 at 11:12am

Edited: 14/03/2010 7:33am

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

Sam

Avatar
Samba Sam

Community Member, 85 Posts

14 March 2010 at 7:34am

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

Thanks,
Sam