10387 Posts in 2198 Topics by 1712 members
| Go to End | Next > | |
| Author | Topic: | 2464 Views |
-
Adding Mollum to a Custom Forim

3 November 2009 at 10:51am
My form page-type was derived from this tutorial. http://www.ssbits.com/creating-a-simple-contact-form/
In fact, the code was the same.This is my form code.
class ContactPage_Controller extends Page_Controller
{
function ContactForm() {
// Create fields
$Params = Director::urlParams();
$fields = new FieldSet(
new TextField('Name', 'Name*'),
new EmailField('Email', 'Email*'),
new TextareaField('Comments','Comments*')
);
// Create action
$actions = new FieldSet(
new FormAction('SendContactForm', 'Send')
);
// Create action
$validator = new RequiredFields('Name', 'Email', 'Comments');
return new Form($this, 'ContactForm', $fields, $actions, $validator);
}I tried changing
return new Form($this, 'ContactForm', $fields, $actions, $validator);to
$form = new Form($this, 'ContactForm', $fields, $actions, $validator);
$protector = SpamProtecterManager::update_form($form, 'Captcha');
if($protector) $protector->setFieldMapping('Name', 'Email','Comments');
return $form;
And it ran fine, but I never see the captcha field.
How can I test out that it is working? I tried out some -spammy- comments such as free viagra and they went through... So Im kinda worried. Should there be something to check before it sends the email?
Or are those 3 lines it?Thanks
-
Re: Adding Mollum to a Custom Forim

3 November 2009 at 1:23pm
You can check to see if the form should display by setting MollomField::$alwaysShowCaptcha = true; in your _config file. This will tell you if your mollom field is added correctly and whether your key works.
-
Re: Adding Mollum to a Custom Forim

3 November 2009 at 1:26pm
I tried it and I got this...
Fatal error: Access to undeclared static property: MollomField::$alwaysShowCaptcha in /home2/fullplat/public_html/mollom/_config.php on line 5
Did I forget installing a module or something?
-
Re: Adding Mollum to a Custom Forim

3 November 2009 at 1:34pm
Sorry perhaps this is a new feature in trunk. Try downloading the mollom daily build and see if you still get that error - http://silverstripe.org/assets/modules/trunk/mollom-trunk-r87203.tar.gz
-
Re: Adding Mollum to a Custom Forim

3 November 2009 at 1:55pm
I think i have to upgrade silverstripe to the .2 version and then upgrade my spam and mollum modules... It's going 2 take some time, but thanks for the info and I will reply if I find anymore trouble (plz subscribe)
Thank you
-
Re: Adding Mollum to a Custom Forim

15 March 2010 at 11:09pm Last edited: 15 March 2010 11:13pm
Hijacking this thread...
Basically trying the same thing, using Mollom with a custom form and form template. I set up a form as usual then:
$actions = new FieldSet(
new FormAction('doContactUs', "submit")
);$form = new ContactUsForm($this, 'contactUsForm', $fields, $actions);
SpamProtectorManager::update_form($form, null, array('Name', 'Email', 'Company', 'Message'));I've gotten as far as the above along with getting Mollom field showing in my form template (truncated):
<form $FormAttributes>
<fieldset>
$dataFieldByName(Name)
$dataFieldByName(Message)
$dataFieldByName(MollomField)
$dataFieldByName(SecurityID)
<% if Actions %>
<% control Actions %>$Field<% end_control %>
<% end_if %>
</fieldset>
</form>However, like anebg my form submits without any indication Mollow is doing anything. It's like there is some hook during form submission missing due to a custom template/form?
I tried your method and download but first I get the same error as anebg when adding the setting to _config.php, then when I update to the download you link I get the error "Class MollomSpamProtector contains 3 abstract methods and must therefore be declared abstract or implement the remaining methods (SpamProtector::getFieldName, SpamProtector::updateForm, SpamProtector::setFieldMapping) in /Users/dlowndes/Sites/bluepacific/webroot/mollom/code/MollomSpamProtector.php on line 45"
In any case, it'd be nice to know if the Mollom module actually works with custom forms and templates so this can be documented (or stated as such). There is not much information on this use case.
I am using the download versions of Mollown and SpamProtector at silverstripe.org/modules.
Cheers
Dave
-
Re: Adding Mollum to a Custom Forim

16 March 2010 at 5:48pm
Should probably note that it doesn't work if you're logged in to the CMS at the time (safe to assume you're not spamming your own site).
Also make sure you have it set up in _config.php:
Mollom::setPublicKey('code_from_mollom');
Mollom::setPrivateKey('other_code_from_mollom');
SpamProtectorManager::set_spam_protector('MollomSpamProtector');Failing that, try have a look in MollomField::validate() to see what it's doing on form submission. Eg find this line:
$response = MollomServer::checkContent($mollom_session_id, $postTitle, $postBody, $authorName, $authorUrl, $authorEmail, $authorOpenId);
and add Debug::show($response) to see what Mollom is saying, assuming it gets that far.
-
Re: Adding Mollum to a Custom Forim

31 January 2011 at 6:31am
Hi!
I hope somebody could confirm if mollom works with custom forms and solve this issue. Thanks!
| 2464 Views | ||
| Go to Top | Next > |



