justb3a

Simple Contact Form

Recommended Posts

Hi @Donald, I recently used this Module and may have some tips, but I don't know it as well as others:

1 hour ago, Donald said:

1. Even if I set "Restrict Submissions" and "Maximum time" very high I can not fill out the form another time for testing purposes. What coud I have probably done wrong? I always get messages like...

I was able to send as many tests as I liked, as long as I had settings:

Minimum time: 1
Maximum time: 300 (i.e. large)
Restrict submissions: 300 (i.e. large)
Exclude IP: 127.0.0.1

Sorry if you have tried exactly this and it doesn't help.

1 hour ago, Donald said:

2. Also I can not find any logfile (at least not in site/modules/simplecontactform) ...???

In the GUI Admin, click Setup > Logs > simplecontactform-log

1 hour ago, Donald said:

3. In the settings area of the module you can also set the fields of the contact form but how can I create a second contact form on another page with totally different fields? 

This is a bit more involved, but essentially read the docs where it tells you how to use an 'options' array, populated with settings. One of the settings in naming the form and naming the fields that form is able to use. Then elsewhere in your template or another template, you do the same but the contents of the 'options' array is different, naming different fields from those available listed in the Module (where you add them). Essentially the Module GUI allows you to insert any fields that will be used across one or more forms and it's the calling of the forms in your code that determines which fields are rendered and used.

I think I have got this correct and I hope it's helpful, very sorry if not.

Good luck!

  • Thanks 2

Share this post


Link to post
Share on other sites

hi @donald

i've never used this module so i cannot provide any support that you requested in the other topic. why don't you just create your own contact form? I'm not talking about creating a module for that. only a template with a simple html form, a honeypot and some lines of code that send you an email and store the results in a page in the backend?

all you need is a form: https://getuikit.com/docs/form

and a template that handles the request (here it handles an ajax request with some json data):

<?php
$email = 'your@mail.com';
$subject = 'your email subject';
$html = "<html><body>";
$formdata = json_decode($formdata);
foreach($formdata as $field) {
    switch($field->name) {
        case 'email':
        case 'name':
        case 'tel':
            $html .= "<p>" . $field->name . ": " . $sanitizer->text($field->value) . "</p>";
            if($field->name == 'email') $email = $sanitizer->email($field->value);
            break;
        case 'message':
            $html .= "<p>" . $field->name . ":<br>---<br>" . nl2br($sanitizer->textarea($field->value)) . "<br>---</p>";
            //${$field->name} = $sanitizer->textarea($field->value);
            break;
        case 'mail':
            // honeypot
            if($field->value) $subject = 'SPAM: '.$subject;
            break;
    }
}
$html .= "</body></html>";

$mail = wireMail();
$mail->to('your@mail.com')->from($email);
$mail->subject($subject);
$mail->bodyHTML($html);
if($mail->send()) { ?>
    <div class="uk-alert uk-alert-success uk-alert-large">
        <p>Thank you!</p>
    </div>
<?php
}
else { ?>
    <div class="uk-alert uk-alert-danger uk-alert-large">
        <p>Error!</p>
    </div>
<?php
}

// save to log that can be viewed via the pw backend
$p = new Page();
$p->template = 'maillogitem';
$p->parent = 1234;
$p->title = date('d.m.Y') . ' - ' . $email;
$p->body = $html;
$p->save();

 

  • Like 6
  • Thanks 1

Share this post


Link to post
Share on other sites
18 hours ago, Donald said:

my personal opinion is that authors should care more about documentation. 

Fell free to improve the documentation! You could easily send a pull request. This is open source. I develop it in my spare time. I don't receive any money doing this. I developed this module for personal use, and thought, it would be nice to share it with others...

On 25/11/2017 at 3:50 PM, Donald said:

but how can I create a second contact form on another page with totally different fields? 

@see: Render multiple instances

18 hours ago, Donald said:

In the log file I always get: Number of fields does not match

To figure out what causes this, it would be a good starting point to provide a bit more information. For example: which fields are added, how do you execute the module---...

  • Like 5

Share this post


Link to post
Share on other sites
Quote

Number of fields does not match

Do you have an email field in the form? Make sure that in this field settings under input -> verify email address is not checked.

the form is counting this field as two fields instead of one and you will get that error.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
16 hours ago, Donald said:

1. Do you also know how to set the options or configure that not just the admin gets an email with the data which was filled in by the sender but also that every sender of an form gets an email back when he/she/(it) filled in a valid email-address?

@see: How to send more than one email

  • Thanks 1

Share this post


Link to post
Share on other sites
On 27/11/2017 at 7:32 PM, Donald said:

3. At the moment are just basic test fields are added like name, street ...

Just basic test fields.. sometimes just some basic fields do break something. If I know that you use an email field with the checked option verify email address, it's pretty easy for me to submit a hotfix and exclude it from the counter. Thanks @maxf5 for pointing it out.

On 27/11/2017 at 7:32 PM, Donald said:

. Also I do not understand when to use the prefix scf_ and when not

You don't have to use the prefix at all. All fields which are added by the module will be prefixed – just to make sure the name has not been chosen yet. Please do not rename scf_website and scf_date because they are used for spam tests. The rest is up to you!

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

Version 1.0.7 excludes email and password confirmation fields from spam count.

@Donald I hope, I've answered all your questions. Now I'm looking forward to merge your pull request to improve the documentation! ;) ^_^

  • Like 2

Share this post


Link to post
Share on other sites

I have two forms, each on different pages, each with `submitName` values that are unique, in case that helps, and I am finding after a succsessful form submission, if I navigate to a new page, then let the page load then go back in history, to the page where the form was sent from, my browser is complaining `Confirm Form Resubmission`.

I can't see anything in the docs on how to clear POST data on a succsessful submission, assuming it's that.

Any pointers/help would be much appreciated :) Thanks in advance 👍

Share this post


Link to post
Share on other sites

Hello! I am trying get the plugin working correctly on my dev server and I am having a weird issue. I can get the fields to work for a few minutes (even so far as being able to use the form and receive an email) but after a few minutes to an hour the plugin resets, clearing the fields and the to email field. Any idea what could possibly cause something like this?

Thanks!

Share this post


Link to post
Share on other sites

@Thomasaurus Always worth checking the anti-spam settings to make sure it's not one of those tripping over. The only other thing I've had that I think was similar was when I had two tabs open, signed in as admin - got weird stuff happening nothing to do with SCF specifically but it affected session info - closed one tab, instant fix. Good luck, I am using this Module more now I am getting familiar with it, it's super useful.

Share this post


Link to post
Share on other sites

Thanks @bernhard by coincidence I am on that exact page now ^_^ I've tried some of this before but not this exact page. It looks like I can 100% solve it by redirecting to a new page (the module allows me to do this), but if I do then the module's nice support for a `Success` message is lost, so no error but also no message.

Gonna keep experimenting to see if I can get the best of both worlds.

Share this post


Link to post
Share on other sites

of course you can! just clear your post data and redirect to the same page. If you do not show the submitted data, then this works (for example if you had a general "thanks for your message").

if you want to show data to the user (like "thanks alan for your message, we'll contact you soon") you could save that data to $session and display it from the session variable after clearing the post data.

edit: actually the post data should get cleared already by the redirect :)

Share this post


Link to post
Share on other sites

Yes, can do that, thanks again @bernhard but it feels like this is something the SCF module does already, e.g. it supports setting a success message in a set of JSON options, and indeed it then shows the message. So all looks 100% ok, unless I nav to some other page, then go back. Maybe a bug in the module (doubt it, more likely a bug in me ;) )

Share this post


Link to post
Share on other sites
Just now, bernhard said:

Ok sorry i shut up since I don't have a clue about this module :)

;) NO! Chat sometimes results in a solution, even if one doesn't know about a thing ;)

Thanks for trying and Happy Christmas in Austria \o/

  • Like 1

Share this post


Link to post
Share on other sites

Hi David,

I just upgraded from ProcessWire v2.8 to v3.0.87, and it offered to automatically upgrade my SimpleContactForm module (from v0.2.1)

This resulted in the following error:

Quote

Error: [] operator not supported for strings (line 133 of .../site/modules/SimpleContactForm/SimpleContactForm.module)

Any ideas how to fix this?

SCF.jpg

Share this post


Link to post
Share on other sites
Posted (edited)

Sorry, deleted my previous wrong answer.

Edited by horst

Share this post


Link to post
Share on other sites
On 1/1/2018 at 10:01 PM, horst said:

Sorry, deleted my previous wrong answer.

It seems the immediate problem is that $this->allFields is a string instead of an array, but the question is why?

Share this post


Link to post
Share on other sites

I just installed this module to do a basic test.

I don't see the error @dougwoodrow sees, but I'm having a problem with mails not being sent.

Log from module: "[ERROR] Mail has not been sent to ..."

Log from Wiremailsmtp_errors: Error in hnsmtp::send : cannot connect to smtp-server!

Share this post


Link to post
Share on other sites
1 hour ago, dragan said:

Log from Wiremailsmtp_errors: Error in hnsmtp::send : cannot connect to smtp-server!

You need to check / debug WireMailSmtp settings, (its module config screen).

  • Like 1

Share this post


Link to post
Share on other sites

Yep - that did it (I installed WireMailSmtp, but I'm not sure I ever actually used it...). Thanks!

Share this post


Link to post
Share on other sites

@dougwoodrow I guess, $this->allFields doesn't return an array due to module update issues v0.2.1 -> v1.0.7. I'm not quite sure if it works to update directly, I tried to keep everything downward compatible, but this is a really huge difference.. You could try to update version by version and always make sure to save module settings. Otherwise you could try to update the module settings json manually (not recommended but maybe the only way; edit column data in table modules, row where class equals SimpleContactForm).

@alan There' s a new module version (1.0.8) which adds an option to prevent form resubmission (activate checkbox in module settings).

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
20 hours ago, justb3a said:

There' s a new module version (1.0.8) which adds an option to prevent form resubmission (activate checkbox in module settings).

@justb3a Thank you very much for this, 100% fixed the problem, cheers!

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By horst
      Croppable Image 3
      for PW 3.0.20+
      Module Version 1.1.16
      Sponsored by http://dreikon.de/, many thanks Timo & Niko!
      You can get it in the modules directory!
      Please refer to the readme on github for instructions.
       
      -------------------------------------------------------------------------
       
      Updating from prior versions:
       
      Updating from Croppable Image 3 with versions prior to 1.1.7, please do this as a one time step:
      In the PW Admin, go to side -> modules -> new, use "install via ClassName" and use CroppableImage3 for the Module Class Name. This will update your existing CroppableImage3 module sub directory, even if it is called a new install. After that, the module will be recogniced by the PW updater module, what makes it a lot easier on further updates.
      -------------------------------------------------------------------------
       
      For updating from the legacy Thumbnail / CropImage to CroppableImage3 read on here.
       
      -------------------------------------------------------------------------
       
    • By MoritzLost
      UPDATE: I have published a stable version of this module!
      Discussion thread:
      Github: https://github.com/MoritzLost/TextformatterPageTitleLinks
      ---
      Hello there,
      I'm working on a tiny textformatter module that searches the text for titles of other pages on your site and creates hyperlinks to them. I'm not sure if something like this exists already, but I haven't found anything in the module directory, so I wrote my own solution 🙂
      It's not properly tested yet and is still missing some functionality I would like to implement, so at the moment it should be considered in BETA. Features include limiting the pages that will get searched by template, and adding a custom CSS class to the generated hyperlinks. As I'm writing this I noticed that it will probably include unpublished and hidden pages at the moment, so yeah ... it's still in development alright 😅
      You can download the module from Github:
      https://github.com/MoritzLost/TextformatterPageTitleLinks
      There's some more information in the readme as well.
      Anyway, let me know what you think! I'm happy about any feedback, possible improvements or ideas on how to improve the module. Cheers.
    • By blad
      Hi guys!
      I just uploaded a module to explore files based on elFinder. By default it will show the "Files" folder.
      Screenshots:

      Video:
       
      To do:
       More options To fix:
       The function of rotating or scaling an image fails  Image editors V 1.01 (view issue)
      Fixed the bug working with the Multi-Language support ( translation of folders ). Fixed the name of elfinder.en  Github:
      https://github.com/LuisSantiago/ProcessElFinder/
      I hope you like it.
    • By BitPoet
      I'm really in love with FormBuilder, but the one thing missing to match all my end users' expectations were repeatable field groups. Think repeaters, in ProcessWire terms. Our primary application of PW is our corporate intranet, so "lines" of fields are quite common in the forms I build. We have all kinds of request forms where the information for a varying number of colleagues needs to be entered (from meal order to flight booking request) and where it is simply impractical to send a form for each, and I don't want to clutter my forms with multiple instances of fields that may only get used ten percent of the time.
      That's why I started to build FormBuilderMultiplier (link to GitHub).
      What it does:
      Adds an option to make a regular Fieldgroup repeatable Lets you limit the number of instances of a Fieldgroup on the form Adds an "Add row" button the form that adds another instance of the Fieldgroup's fields Adds a counter suffix at the end of every affected field's label Stores the entered values just like regular fields Makes the entered values available in preview and email notifications Supports most text based fields, textareas and selects (really, I haven't had enough time to test all the available choices yet) What it doesn't do (yet):
      Support saving to ProcessWire pages (i.e. real Repeaters) I haven't tested all the validation stuff, Date/Time inputs etc. yet, but since I'm utterly swamped with other stuff at work, I didn't want to wait until I have it polished. Any feedback is welcome. There might also be some issues with different output frameworks that I haven't encountered yet. The forms I work with mostly use UIKit.
      Status:
      Still alpha, so test well before using it in the field.
      Known issues:
      When rows are added, the form's iframe needs to be resized, which isn't completely clean yet.
      How it works:
      The Fieldgroup settings are added through regular hooks, as is the logic that adds the necessary field copies for processing the form and displaying previews.
      "Multiplied" field instances are suffixed with _NUM, where NUM is an incremental integer starting from 1. So if you have add two fields named "surname" and "givenname" to a fieldgroup and check the "multiply" checkbox, the form will initially have "surname_1" and "givenname_1" field (I'm still considering changing that to make the risk to shoot oneself into the foot by having a regular "surname_1" field somewhere else in the form less likely).
      When a "row" is added, the first row is cloned through JS and the counter in the fields' IDs, names and "for" attributes as well as the counter in the label are incremented before appending the copies to the Fieldset container in the form.
      To keep backend and frontend in sync, a hidden field named [name of the fieldset]__multiplier_rows is added to the form. Both the backend and the frontend script use this to store and retrieve the number of "rows".
      ToDo:
      Naturally, add the option to store the data in real repeaters when saving to pages. Do a lot of testing (and likely fixing). Make a few things (like the "Add row" button label etc.) configurable in field(set) context. Add a smooth API to retrieve the multiplied values as WireArrays. The mandatory moving screenshot: