justb3a

Simple Contact Form

Recommended Posts

On 07/01/2018 at 6:10 PM, justb3a said:

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

Thanks for replying.  I tred updating the JSON manually to change allFields from a simple string to an array, which solved the initial problem, but then I got other errors with the scf-messages page in particular... I seem to have got my system into a proper mess so will probably need to reinstall from scratch.

One thing that puzzles me is that the documentation has changed a lot since version 0.2.1 - I can't see any reference to the scf-messages page at all in version 1.07 for example.

Share this post


Link to post
Share on other sites

@dougwoodrow It changed a lot, for example in the initial version the module generated a template file, so that everybody could adapt the html (form) structure as needed. But it turned out that this led to a lot overhead for me to support it. Furthermore I lost the possibility to use the ProcessWire way of handling form inputs, setting error messages, validation, form processing and so on. Therefore I decided to generate the complete form and offer as many options as possible to be able to adapt the markup / classes. Saving messages is still possible – with the difference that you're able to define the `save-messages-template` as well as the `parent`. So handling multiple (different) forms  isn't a problem...

  • Like 1

Share this post


Link to post
Share on other sites

Hi there, 

I was wondering if it is possible to use an image field with the popular "Simple Contact Form" of @justb3a

When I tried I got the following error message (without even "uploading" an image):

Call to a member function path() on null in C:\xampp\htdocs\pw2\wire\modules\Fieldtype\FieldtypeFile.module on line 184


As I don't want to save messages on the server (so just sending an image), it shouln't be a security issue, I guess.

But is it possible to use an image field with the SimpleContactForm module? 

Share this post


Link to post
Share on other sites

Is it possible to create a custom spam message?  Along the lines of:

$modules->get('SimpleContactForm')->render(array(
	'spamMessage' => 'Custom Spam Message'
));

 

Share this post


Link to post
Share on other sites

Hi all. Great module, Justb3a. It was easy to set up and get working, submitting to the same page without Ajax. Now I'm trying to do it with Ajax but something's not right: when I submit a blank form (expecting errors for required fields), the form disappears from the page without any notice (and without refreshing, so it's sort of working). Same if I submit the form with all the fields filled-in (I expect a Success message and no form, as without Ajax). I don't get any console errors.

I've included the simplecontactform.js and initialised it per the instructions. My contact-page.php looks something like this:

<?php
if ($config->ajax) {
	$modules->get('SimpleContactForm')->render();
} else {
include("./includes/head.inc");
?>
... 
<div class="row row-2">
    <div class="col">
        <?php echo $page->body; ?>
        <div><!-- if I remove this div, the entire .col div disappears -->
            <?php echo $modules->get('SimpleContactForm')->render(); ?>
        </div>
    </div>
...
<?php
include("./includes/foot.inc");
} ?>

Am I doing something wrong here? Any suggestions are greatly appreciated.

Share this post


Link to post
Share on other sites

hi all,

i've got some trouble submitting the form.
in the logs i've got a "Date difference is out of range" - notification, every time a form has been submitted.

i double checked all available and required fields.

Do you have any idea?

Thanks

CF: 0.1.0
PW: 2.6.10

Share this post


Link to post
Share on other sites

Ok, I'm revisiting this. I guess I need to echo the form when I use Ajax:

if ($config->ajax) {
	echo $modules->get('SimpleContactForm')->render();
} else {

Now the form works fine with one exception: when I submit the form with required fields empty, ajax works and I get the red 'Missing required field' text, but when I submit a second time (with or without entering data in a required field), the page submits without Ajax (i.e., it refreshes). I suspect it's a jquery thing; any suggestions?

Here's the work-in-progress: http://bullocks-ley.strandoo.com/contact-us/. Thanks in advance.

 

Share this post


Link to post
Share on other sites

I'm trying to install the module on PW 3.0.42 but get an error:

Parse Error: syntax error, unexpected '[', expecting '}' (line 182 of /var/www/clubmoral_com/site/modules/SimpleContactForm/SimpleContactForm.module) 
 

Share this post


Link to post
Share on other sites

maybe you are using an old php version that does not support short array syntax [ ] ?

  • Like 1

Share this post


Link to post
Share on other sites

Hi,

is there a clean way (not touching the module) to get fields labels instead of fields name in the email content text?

//Line 464
foreach ($this->allFields as $inputfield) {
	$message[] = $inputfield .': ' . $this->sanitizer->textarea($this->input->post->{$inputfield});
}

to something like this (not working...)?

//Line 464
foreach ($this->allFields as $inputfield) {
	$message[] = $inputfield->label .': ' . $this->sanitizer->textarea($this->input->post->{$inputfield});
}

thanks!

---

Amendment: Here's how I've approached to get this done, maybe someone else might be interested:

$message = array();
$message[] ='Some description...';
$message[] = '---';
$message[] = 'Name Surname: ' . $input->post->mail_name;
$message[] = 'Partecipa il 7 Luglio? ' . ($input->post->mail_option_01 == 1 ? 'Si.' : 'No.');
$date = new \DateTime();
$message[] = 'Date: ' . $date->format('Y-m-d');
$emailText = implode("\r\n", $message);

// in option array 
'emailMessage' => $emailText,

Cheers!

Share this post


Link to post
Share on other sites
On 7/19/2017 at 9:58 PM, szabesz said:

So you either have to downgrade to PHP 7.0.x or wait for @justb3a to update the module. You can "hack it" too, either by actually changing the module's code or you can try the "multiple copies of the same module" technique:

https://processwire.com/blog/posts/processwire-core-updates-2.5.14/

I never did the latter, BTW.

I had a vicious [] operator not supported for strings (line 133 ….) - problem, after casually upgrading the module. I could not access the backend anymore. I had PHP 5.6 running and tried out 7.0 and 7.1 without success. Then in my desperation I resolved to fiddling the module code (I have pretty weak PHP knowledge).  In simplecontactform.module, line 133 , I changed

foreach (self::$additionalFields as $f) $allFieldsExtended[] = $f;

to

foreach (self::$additionalFields as $f) $allFieldsExtended = (array)$f;

and at least I was again able to keep on working. But I don't know, whether the module is working fine now, as I have my contact form without module.

Might help some poor guy one day...

Share this post


Link to post
Share on other sites

I had the same problem and used the solution above. The module works now without the error, but it just doesn't work. Doesn't send me an email when the form is filled and doesn't save the message as a page.

Share this post


Link to post
Share on other sites

Just a quick question, as I wasn't able to find any answer over this tread: is the scf module capable of manage file uploads (therefore send email with attachments)?

Because my form gets error as soon as I attach a fileUpload fieldtype to the form, so no way for me to manage it

Much appreciated

Share this post


Link to post
Share on other sites
On 6/14/2018 at 4:09 PM, Federico said:

Just a quick question, as I wasn't able to find any answer over this tread: is the scf module capable of manage file uploads (therefore send email with attachments)?

Because my form gets error as soon as I attach a fileUpload fieldtype to the form, so no way for me to manage it

Much appreciated

I've never used this module yet (so I don't know if that is possible or not), but as you didn't get any answer yet, you might be interested in my forms module: 

 

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 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 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:

    • By MoritzLost
      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 adrian
      This module provides a way to rapidly generate Page fields and the required templates and pages for use as a drop down select (or any other Page field type).
      This module will let you create a full page field setup in literally a few seconds 
      To use, run Page Field Select Creator from the Setup Menu
      Enter a Field Title, eg: Room Types Select Options - These will become the child pages that will populate the page field select options. There are two different options.
       
      Option 1. TITLE FIELD ONLY - enter one option per line, eg:
       
      Single
      Double
      Suite
       
       
      Option 2. MULTIPLE FIELDS - the first line is used for the field names and the first field must be 'Title'. Subsequent lines are the values for the fields, eg:
       
      Title, Number of Beds, Number of People, Kitchen Facilities
      Single, 1, 1, Fridge Only
      Double, 2, 2, Fridge Only
      Suite, 3, 6, Full Kitchen
        Choose the parent where the page tree of options will be created, eg a hidden "Options" parent page Select a "Deference in API as" option depending on your needs Choose the input field type Check whether "Allow new pages to be created from field?" should be enabled. As an example, if you entered "Room Types" as the field title, you would end up with all of the following automatically created:
      a fully configured page field called: room_types MULTIPLE FIELDS OPTION - 3 additional fields - number_of_beds, number_of_people, kitchen a parent template called: room_types a child template called: room_types_items (with either just a title field, or with the 3 additional fields as well) a parent page called: Room Types a series of child pages named and titled based on the per line entries in the Select Options textarea The templates are configured such that the "room_types_items" child template can only have the main "room_types" template as a parent, and vice versa.

      Then all you have to do is add the newly created page field to any template you want and you're ready to go!
       
      You can grab it from:
       
      Modules directory: http://modules.processwire.com/modules/process-page-field-select-creator/
      Github: https://github.com/adrianbj/ProcessPageFieldSelectCreator
       

    • By bernhard
      WHY?
      This module was built to fill the gap between simple $pages->find() operations and complex SQL queries.
      The problem with $pages->find() is that it loads all pages into memory and that can be a problem when querying multiple thousands of pages. Even $pages->findMany() loads all pages into memory and therefore is a lot slower than regular SQL.
      The problem with SQL on the other hand is, that the queries are quite complex to build. All fields are separate tables, some repeatable fields use multiple rows for their content that belong to only one single page, you always need to check for the page status (which is not necessary on regular find() operations and therefore nobody is used to that).
      In short: It is far too much work to efficiently and easily get an array of data based on PW pages and fields and I need that a lot for my RockGrid module to build all kinds of tabular data.

      Basic Usage

       
      Docs & Download
      https://modules.processwire.com/modules/rock-finder/
      https://github.com/BernhardBaumrock/RockFinder
       
      Changelog
      180817, v1.0.6, support for joining multiple finders 180810, v1.0.5, basic support for options fields 180528, v1.0.4, add custom select statement option 180516, change sql query method, bump version to 1.0.0 180515, multilang bugfix 180513, beta release <180513, preview/discussion took place here: https://processwire.com/talk/topic/18983-rocksqlfinder-highly-efficient-and-flexible-sql-finder-module/