Jump to:

11004 Posts in 2735 Topics by 1824 members

All other Modules

SilverStripe Forums » All other Modules » Adding Mollum to a Custom Forim

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 3219 Views
  • merrick_sd
    Community Member
    95 Posts

    Re: Adding Mollum to a Custom Forim Link to this post

    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.

Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.