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, Ed, biapar, Willr, Ingo, swaiba

Adding Mollum to a Custom Forim

Go to End

9 Posts   4641 Views


Community Member, 99 Posts

22 November 2012 at 2:12am

Edited: 22/11/2012 3:17am

Access to undeclared static property: MollomField::$alwaysShowCaptcha

maybe its called $always_show_captcha

mollom> code > MollomField.php
line 15 static $always_show_captcha = false;

I was going to start a new topic as I'm trying to do a custom form using bootstrapform with mollom using SS 3.0.2.

mystie > config



  MollomServer::setPublicKey('yes thats there');
  MollomServer::setPrivateKey('yes thats thre');

mysite > code > ContactPage.php

class ContactPage_Controller extends Page_Controller
	//Define our form function as allowed
	static $allowed_actions = array(
	//The function which generates our form
	function ContactForm() 
      	// Create fields
	    $fields = new FieldList(
		      ->setSource(array('Mr.' => 'Mr.', 'Ms.' => 'Ms.', 'Mrs.' => 'Mrs.', 'Dr.' => 'Dr.', 'Rev.' => 'Rev.')), 
	   TextField::create("DaytimeTel")->setTitle('Daytime Contact Number'),
	   TextField::create("EveningTel")->setTitle('Evening / Weekend Contact Number'),
		new EmailField('Email', 'Email*'),
		new TextareaField('Comments','Enquiry*')
	    // Create action
	    $actions = new FieldList(
	  	FormAction::create('SendContactForm', 'Send')
		// Create validation
		$validator = new RequiredFields('Prefix','FirstName', 'Surname', 'Email', 'Comments');
		//return form fields,actions, validation
	   $form = BootstrapForm::create($this, 'ContactForm', $fields, $actions, $validator)->addWell()
	    // form fields and mollom fields mapping
	    $fieldMap = array('Prefix' => 'Prefix', 'FirstName' => 'FirstName', 'Surname' => 'Surname', 'Email' => 'Email', 'DaytimeTel' => 'DaytimeTel', 'EveningTel' => 'EveningTel','Comments' => 'Comments');
	    // Update the form to add the protector field to it
	    $protector = SpamProtectorManager::update_form($form, null, $fieldMap);
	    return $form;
	//The function that handles our form submission
	function SendContactForm($data, $form) 
	$DataContactSubmission = new ContactSubmission();
	 	//Set data
		$From = $data['Email'];
		$To = $this->Mailto;
		$Subject = "HMY: Website Contact message";  	  
		$email = new Email($From, $To, $Subject);
		//set template
		//populate template
		//send mail
	  	//return to submitted message
		Director::redirect(Director::baseURL(). $this->URLSegment . "/?success=1");


	//The function to test whether to display the Submit Text or not
	public function Success()
		return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";

adding $always_show_captcha =true; to the mysite config got it to show.

I wasn't able to submit without getting the captcha correct.

note: there was no message when i got it wrong though! .. it just wouldn't let e get to the success page.

look on my other sites that use the userform module and ss2.whatever and the mollow files says
"Complete the words in the image"
and then on error
"You didn't type in the correct captcha text. Please type it in again."

I have also added Debug::show($response); on line 158 in mollomField.php

	$this->mollomFields['session_id'] = $session_id;
		$response = MollomServer::checkContent(

partly solved
From what i can tell its rather important you map field names to at least ONE to be checked.

ie: actually try and match them up with


$fieldMap = array('Prefix' => 'Prefix', 'FirstName' => 'author_name', 'Surname' => 'author_name', 'Email' => 'author_mail', 'DaytimeTel' => 'DaytimeTel', 'EveningTel' => 'EveningTel','Comments' => 'post_body');

this has got the capatch to display and it works.

but there is still nothing in the way of helpful text to guid the end user.

Go to Top