Jump to content

Simple Contact Form


justb3a

Recommended Posts

Just a simple contact form including spam protection.
Optional support for Twig (TemplateTwigReplace) as template engine.
 
---
 
Please have a look at the readme on github!
If you upgrade from version 0.0.9 and below, there are some extra steps to be taken.

The Guides

Edited by justb3a
Added the "module" tag and removed it from title.
  • Like 27
Link to comment
Share on other sites

This is great. I thought about doing a contact form module myself as i would have needed it in nearly every single project we've done recently.

Btw: I like that all of your modules support TemplateTwigReplace! :)

Link to comment
Share on other sites

Very nice.. just tryed it out and works perfectly.

I had a little trouble with ajax but sorted out in the end.

My fault for copy and pasting from the instructions but this code below needs to be changed:

if ($('.js-simplecontactform').length) {
  $.simplecontactform($('.js-simplecontactform'));
}

to

if ($('.js-simple_contact_form').length) {
   $.simplecontactform($('.js-simple_contact_form'));
}

just a matter of class name if using the default class of the form in simple_contact_form.php

  • Like 2
Link to comment
Share on other sites

Hello, 

I was glad to find this module, cause that was just what I looked for.. but I upload the module and when I Install it, I have an error : Method Modules::getInstall does not exist or is not callable in this context

But If I go back in the module page, It seems well installed (I have access to the settings), but when I call the form in my template, an error appears : Error Exception: Method Modules::getInstall does not exist or is not callable in this context (in /home/www/d7a3bc5db5bed31cde906ac7976f3d83/web/wire/core/Wire.php line 231)

Any ideas ? Maybe I skipped a step...

I'm not a Master in PW, but I globally understand how it works..

Thanks in advance.

Link to comment
Share on other sites

Hi @nyo08,

which version of ProcessWire are you using?

I found a similar error and changed my code as explained.

Please clone the module (github) and checkout  hotfix/2.4-dependency and try again. And please let me know if everything works as expected.

I tested it (ProcessWire 2.5.3) without any problems.

git clone git@github.com:justonestep/processwire-simplecontactform.git SimpleContactForm
cd SimpleContactForm
git checkout  hotfix/2.4-dependency
Link to comment
Share on other sites

Hi @nyo08,

which version of ProcessWire are you using?

I found a similar error and changed my code as explained.

Please clone the module (github) and checkout  hotfix/2.4-dependency and try again. And please let me know if everything works as expected.

I tested it (ProcessWire 2.5.3) without any problems.

git clone git@github.com:justonestep/processwire-simplecontactform.git SimpleContactForm
cd SimpleContactForm
git checkout  hotfix/2.4-dependency

Indeed I update my PW (I had the 2.2.4 version... looks like I miss some update ahah) and that's perfecly work

O0

Link to comment
Share on other sites

  • 2 weeks later...

@makari: This module creates a simple template, you can / should change the html structure as well as the label texts. If you need multi language support you have to change the text like this echo __("the label text here!"). Now you can translate the labels via Processwire Backend.

@horst: Thats a good point but first I have to finish another project. I will keep it in mind – as some other things (I did not forget your message  ;) ).

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Hey there,

I've installed this module. It has created a new template simple_contact_form.php

I've created a page and used simple_contact_form.php as its template

So I see the contact form on the new page, but it doesn't seem to work (I've used my @gmail.com as emailTo)

is there anything else I should do to make it work?

Link to comment
Share on other sites

but it doesn't seem to work (I've used my @gmail.com as emailTo)

Gmail doesn't allow you to send an email from yourself to yourself, unlike other email platforms.  The message gets sent but you don't receive the copy, since if's from yourself.

Link to comment
Share on other sites

Ok, then I would then look at the php mail function on your server.  I believe this module doesn't make use of enhanced PW capabilities for email sending.

It would be great if the wireMail function could be used for sending emails instead of the php mail function.
 
This way people would be able to use it together with their favourite mail extensions. For example with SMTP support: wiremail-swiftmailer or wiremailsmtp
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Hi,

Just experienced a couple of bugs with this module which happen when the save messages setting is off.

SimpleContactForm.module

First bug:

if (!$this->pages->findOne('name=' . $this->pageName) instanceof Pages) {

I believe this should be without the "!" at the start as it is currently the wrong way around. Removing it fixed it for me.

Next bug:

} elseif (!in_array($currentIp, $excludeIps)) {

This line should also check if the saveMessages setting is on, i.e.:

} elseif (!in_array($currentIp, $excludeIps) && $this->saveMessages) {

I haven't tested any of these with other settings and I'm not sure they are correct - just needs some looking into.

  • Like 1
Link to comment
Share on other sites

@pwired:

@makari: This module creates a simple template, you can / should change the html structure as well as the label texts. If you need multi language support you have to change the text like this echo __("the label text here!"). Now you can translate the labels via Processwire Backend.

@BrettMW: Indeed, I only tested this at the beginning with save message settings deactivated. Thanks for your feedback, I will test and implement this as soon as possible. 

Link to comment
Share on other sites

New version 0.0.9 includes fixes for deactivated save message setting.

On line :343 I removed the exclamation mark (!) and I corrected the instance to compare with. This has to be Page instead of Pages because findOne returns a single page (because of this double bug the messages has been stored). I included a second check here just to make sure that save messages is on. I also included this additional check on line :396. 

  • Like 3
Link to comment
Share on other sites

  • 3 weeks later...

New version 0.1.0 adds some more spam protection possibilities and logging.

  • CSRF validation
  • mark messages as spam (by mail or/and ip address)
  • logging for received messages and spam
  • sort option for repeater items in backend to get the latest to the beginning of the list

For more information have a look at the readme.

NOTICE: If you upgrade an existing installation from 0.0.9 and below to the current version, there are some steps to be taken.

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...