create($protector); } } else { $protector = Config::inst()->get('FormSpamProtectionExtension', 'default_spam_protector'); $protector = Injector::inst()->create($protector); } return $protector; } /** * Activates the spam protection module. * * @param array $options */ public function enableSpamProtection($options = array()) { // captcha form field name (must be unique) if(isset($options['name'])) { $name = $options['name']; } else { $name = 'Captcha'; } // captcha field title if(isset($options['title'])) { $title = $options['title']; } else { $title = ''; } // set custom mapping on this form $protector = self::get_protector($options); if(isset($options['mapping'])) { $protector->setFieldMapping($options['mapping']); } // add the form field if($field = $protector->getFormField($name, $title)) { $field->setForm($this->owner); $this->owner->Fields()->push($field); } return $this->owner; } }