FormIt - MODX Community Forums <![CDATA[Formit and QuickEmail nothing sent]]> Tue, 19 Feb 2019 10:37:10 +0000 <![CDATA[New FormIt Hook and Prehook to prevent bot attacks.]]> So I created a cool-down hook to slow the bots down. Most people do not submit form twice so quickly.

It is working for me, but I was wondering if anyone else could use it, and or did I miss a feature.
The prehook creates a session with a timestamp. The hook compares it to the time and a delay.

$waitSessionName = $modx->getOption('waitSessionName', $formit->config, 'waitSession');
if (!isset($_SESSION[$waitSessionName])) {
	$_SESSION[$waitSessionName] = time();
// debug
// $hook->setValue('session', $_SESSION[$waitSessionName] . ' - ' . time());
return true;

$waitSessionName = $modx->getOption('waitSessionName', $formit->config, 'waitSession');
$delay = $modx->getOption('delay', $formit->config, 15);
$delayPenalty = $modx->getOption('delayPenalty', $formit->config, 30);

$delayTimer = ($_SESSION[$waitSessionName] - time()) + $delayPenalty;
$s = $delayTimer%60;
$dTm = floor(($delayTimer % 3600) / 60);
$dTh = floor(($delayTimer % 86400) / 3600);
$m = $dTm>0?$dTm.' minute'.($dTm>1?'s':''):'';
$h = $dTh>0?$dTh.' hour'.($dTh>1?'s':''):'';

$timeRemaining = "$h $m $s seconds" . ' ' . $_SESSION[$waitSessionName] . ' ' . $delayTimer;

$waitErrorMsg = $modx->getOption('waitErrorMsg', $formit->config, 'Too soon, please wait [[!+timeRemaining]]');

if ($_SESSION[$waitSessionName]+$delay <= time()){
  $_SESSION[$waitSessionName] = time();
  return true;
} else {
  $_SESSION[$waitSessionName] = time() + $delayTimer;
  $modx->log(modX::LOG_LEVEL_INFO, $_SESSION[$waitSessionName]);
  $modx->setPlaceholder('timeRemaining', $timeRemaining);
  return false;

Test Form
<h1>Session Form</h1>
<span class="errors">[[!+fi.error.waitError]]</span>
<form action="[[~[[*id]]]]" method="post" class="form">
    <div class="form-row">
        <label for="session">Session</label>
        <input type="text" name="session" size="50" autocomplete="off" class="form-field" value="[[!+fi.session]]"/>
    <button type="submit" class="submit-button">Submit</button>
]]> Mon, 18 Feb 2019 04:21:01 +0000
<![CDATA[ [SOLVED] FormIt not sending mail on localhost]]> I’ve just recently made the change from Evolution to Revolution and am having trouble getting FormIt to actually send email.

I’m sure this is a really newb question but I’d be very grateful for any help as I’ve been unable to find an answer.

Basically the form is set up and validating fine, but when I hit submit it just refreshes the existing page. Below is my code:

The contact form (template):

   &emailSubject=`Enquiry via website`

    [[!+fi.error.error_message:notempty=`<p class="error">[[!+fi.error.error_message]]</p>`]] 

    <form action="[[~[[*id]]]]" method="post" id="contact-form">

        <label for="name" >Name<span class="error">[[]]</span></label>
        <input type="text" name="name" maxlength="60"  value="[[]]" />

        <label for="email" >Email<span class="error">[[]]</span></label>
        <input type="text" name="email" size="40" maxlength="40"  value="[[]]" />

        <input type="hidden" name="phone" value="" /> 

        <label for="text">Message<span class="error">[[+fi.error.text]]</span></label>
        <textarea cols="40" rows="7" name="text" value="[[+fi.text]]">[[+fi.text]]</textarea>

        <input type="image" name="submit" class="submit" alt="Send" src="assets/images/global/send.png" />


sent_email_template (chunk):

<br />[[+name]] ([[+email]]) Wrote: <br />  [[+text]] 

Any idea if it’s something wrong with my code, or a setting in modx or the FormIt package I need to change?

Many thanks in advance for any help you can give me.

Harmony]]> Tue, 29 Jan 2019 07:45:04 +0000
<![CDATA[Formit upgrade to 4.1.0 has messed up all previously encrypted stored form data]]>
What a pain!


dubbs.]]> Fri, 02 Nov 2018 07:55:02 +0000
<![CDATA[Multipage and FormitRetreiver and &store Issue]]>
Step (Page 1)

    &validate=`donation_type:required, amount:required`

Step 2 (Page 2)
 [[!FormIt? &submitVar=`regular-donation` &hooks=`redirect` &store=`1` &validate=`nospam:blank,email:email:required,DonorTitle:required,Donor_FirstName:required,Donor_LastName:required` &redirectTo=`4` ]]

To this stage all works well the information from Page 1 has been stored and appears in the hidden fields of Page 2

Step 3 (Page 3)
 [[!FormIt? &submitVar=`dd_donation` &hooks=`email,redirect` &validate=`nospam:blank,email:email:required,DonorTitle:required,Donor_FirstName:required,Donor_LastName:required,Donation_Frequency:required` &emailTpl=`regular_donation_emailTpl` &emailTo=``  &redirectTo=`5` ]]

However the fields from Page 2 do not appear, the fields from Page 1 do... The form does not submit because the fields that should appear from Page 2 are not there and these are required fields.

Suggestions please as to why the &store=`1` doesn't appear to be storing the data from Step 2 to Step 3.

Thank you


MODX Cloud
Revo 2.5.0
Formit 2.2.10]]> Mon, 22 Oct 2018 05:02:13 +0000
<![CDATA[Failed Formit 4.1.0 upgrade and now no manager!]]>
Any ideas what is going on and how to fix???

Looks like same issues here >]]> Wed, 17 Oct 2018 03:00:08 +0000
<![CDATA[FormIt Action to Existing PHP Processor]]>
I am running into an issue where I have an existing PHP processor with my CRM where presently I have a form stored in a chunk with the action pointed at my CRM (action="").

I want to use FormIt to validate fields and then send the form to my existing action point.

What is the best approach here?
]]> Mon, 24 Sep 2018 03:46:44 +0000
<![CDATA[Formit not working]]>
Here's my code which is a cut-down version of the instructions from

   &emailFrom=`` /* changed to protect the innocent */
   &emailSubject=`Portofino FormIt Form`

<h2>Contact Form</h2>
<form action="[[~[[*id]]]]" method="post" class="form">
    <input type="hidden" name="nospam:blank" value="[[+fi.nospam]]" />
    <label for="name">
        <span class="error">[[!]]</span>
    <input type="text" name="name" id="name" value="[[!]]" /><br />
    <label for="email">
        <span class="error">[[!]]</span>
    <input type="text" name="email" id="email" value="[[!]]" /><br />
    <label for="subject">
        <span class="error">[[!+fi.error.subject]]</span>
    <input type="text" name="subject" id="subject" value="[[!+fi.subject]]" /><br />
    <label for="text">
        <span class="error">[[!+fi.error.text]]</span>
    <textarea name="text" id="text" cols="55" rows="7" value="[[!+fi.text]]">[[!+fi.text]]</textarea><br /><br />
    <br class="clear" />
    <div class="form-buttons">
        <input type="submit" value="Send Contact Inquiry" />

and my chunk:

This is the Formit Email Chunk.
<br />[[+name]] ([[+email]]) Wrote: <br />

the test page can be viewed at

What I have tried:

- Bob's QuickEmail snippet which works no problem (thanks Bob I sent you a donation)

- a simple phpmail() snippet which works no problem

mail("","php mail test","this works if you are reading it","From:");

- installing the same code at another site (hosted by hostgator) which works no problem

I can only conclude there is nothing fundamentally wrong with my code, but rather something queer about the interaction of formit and the host.

Any suggestions out there or do I just 'roll my own form' and abandon formit? Two days wasted on this already sad

MODx 2.3.1 traditional
MySQL 5.0.77
PHP Mailer 5.2.8 (can't view phpinfo they have blocked it's use server-side)]]> Mon, 20 Aug 2018 06:33:20 +0000
<![CDATA[How to create Resources from the front end FormIt 4.0?]]> Snippets from here
not working.

Anyone can help, please?]]> Sun, 19 Aug 2018 08:13:46 +0000
<![CDATA[FormIT 4.0 update broke manager login]]> The error is:
mod_fcgid: stderr: PHP Parse error: syntax error, unexpected '[' in /home/webs60/public_html/core/components/formit/src/FormIt.php on line 24

I installed it on another site to see if it was an update issue and the same thing happened with the same error and stopping me from logging into manager.

Line 24 is:
public $config = [];

Any ideas?]]> Wed, 15 Aug 2018 09:31:05 +0000
<![CDATA[SOLVED: Custom Formit Hook]]>
I'm having a little issue with a Formit Hook that I made for a 3PC I'm working on. This might be a case of me just staring at it too long and missing something obvious (I'm hoping) so I figured I'd ask here for a new set of eyes.

The Formit call for adding items to my db is as follows:

The hook code is as follows:
$easyrestaurant = $modx->getService('easyrestaurant','Easyrestaurant',$modx->getOption('easyrestaurant.core_path',null,$modx->getOption('core_path').'components/easyrestaurant/').'model/easyrestaurant/',$scriptProperties);
if (!($easyrestaurant instanceof Easyrestaurant)) return '';

$edit = $hook->getValue('edit');
$itemid = $hook->getValue('itemid');

if($edit == 1) { $easyrestaurant_hook = $modx->getObject('erItems',$itemid); } else { $easyrestaurant_hook = $modx->newObject('erItems'); }
if (empty($easyrestaurant_hook)) {return 'I didn\'t get an object..';}
return true;

Editing items works great... Things are saving to the database successfully.. no problems there.

For some reason...I can't create new items though. The form is completely processed and returns with the success param, but no new items are in the database.

My initial inclination was that I was passing the edit field to the form accidentally and it was trying to edit an item that didn't exist, but I did some error checking there and it appears to be properly executing the "else" statement.

What are my tired eyes missing?

Thanks in advance!
-Jared]]> Tue, 07 Aug 2018 01:35:32 +0000
<![CDATA[Formit 4.1.0 on Revo 2.6.5]]>
An error occurred while trying to send the email. SMTP connect() failed.

Error logo shows these:

[2018-07-30 21:13:22] (ERROR @ /public_html/core/components/formit/src/FormIt/Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.
[2018-07-30 21:13:22] (ERROR @ /public_html/core/components/formit/src/FormIt/Hook/Email.php : 303) [FormIt] An error occurred while trying to send the email. SMTP connect() failed.

Any ideas?]]> Tue, 31 Jul 2018 08:11:52 +0000
<![CDATA[Formatting checkboxes when displaying results with FormItRetriever]]>
Got a question that's been bugging me all morning as I try to convert an email form to one that displays on a webpage for the user to then print. I have a form set up with FormIt so that when the user hits submit, it goes to a new page and displays all the form fields with FormItRetriever. It's a nitpick, but I want to display checkbox values on separate lines, rather than the default comma separated.


value 1
value 2

rather than

value 1,value 2

With email, I know I can format this with &emailMultiWrapper and &emailMultiSeparator in the FormIt call. Is there any way to do this with FormItRetriever?

Thanks in advance,

Kahli]]> Fri, 27 Jul 2018 01:56:13 +0000
<![CDATA[FormIt 4.0 / 4.1 "Fatal error: Class 'Sterc\FormIt' not found"]]>
I was about to update FormIt from 3.0.4 to the latest version 4.1.0.

My contact form works fine under 3.x and prior, but for any 4.x version my page shows following error:

Fatal error: Class 'Sterc\FormIt' not found in /www/htdocs/###/core/components/formit/model/formit/formit.class.php on line 28

I had a look at this file, and it has changed from prior versions. For now I reverted back to 3.0.4 but would like to figure out what went wrong.

I'm running my page with MODX Revolution 2.6.3-pl under PHP7.0.

Does anyone have similar issues, or an idea what the issue may be?

Thank you
Mark]]> Tue, 26 Jun 2018 11:31:20 +0000
<![CDATA[How to collect different forms to one result?]]>
I'm using a formit to a resultpage (id=12) where I want to show both name1 and name2. I use the store-function of FormIt to keep the data in session.

[[!FormItRetriever? &storeLocation=`session`]]


on the resultpage I call [[+fi.name1]] and [[+fi.name2]]

The problem is that only the last filled in name is showed on the resultpage. So if I last fill in name2 then name1 is blank on the resultpage and name2 is filled in and vice versa.

Am I getting crazy or why is this not working?]]> Thu, 07 Jun 2018 06:47:50 +0000
<![CDATA[How to display success message?]]>
&emailSubject=`Request from [[+formName]]`
&successMessage=`Your comment has been submitted successfully.`
&validationErrorMessage=`<div class="alert alert-error">
<h3>Please review the following errors:</h3>
[[!+fi.error.formName:!empty=`<li><a href="[[~[[*id]]]]#formName">Name is a required field</a></li>`]]
[[!+fi.error.formEmailAddress:!empty=`<li><a href="[[~[[*id]]]]#formEmailAddress">Email is a required field</a></li>`]]

<div class="alert alert-error xjtlurequest">
<h3>Please review the following errors:</h3>
[[!+fi.error.formName:!empty=`<li><a href="[[~[[*id]]]]#formName">Name is a required field</a></li>`]]
[[!+fi.error.formEmailAddress:!empty=`<li><a href="[[~[[*id]]]]#formEmailAddress">Email is a required field</a></li>`]]


<div class="well xjtlurequest">
<form method="post" action="[[~[[*id]]]]" id="[[+formId:default=`contact-us`]]" enctype="multipart/form-data">
<legend>Contact Us</legend>
<input type="hidden" value="[[*pagetitle]]" name="formPage" id="formPage">
<label for="formName">Name [[!+fi.error.formName:notempty=`[[!+fi.error.formName]]`]]</label>
<input type="text" name="formName" id="formName" value="[[!+fi.formName]]">
<label for="formEmailAddress">Email [[!+fi.error.formEmailAddress:notempty=`[[!+fi.error.formEmailAddress]]`]]</label>
<input type="email" name="formEmailAddress" id="formEmailAddress" value="[[!+fi.formEmailAddress]]">
<label for="formPhoneNumber">Telephone [[!+fi.error.formPhoneNumber:notempty=`[[!+fi.error.formPhoneNumber]]`]]</label>
<input type="text" name="formPhoneNumber" id="formPhoneNumber" value="[[!+fi.formPhoneNumber]]">

<label for="teamselect">Please chose a thing for requesting....
<select name="teamselect">
<option value="" [[!+fi.teamselect:FormItIsSelected=``]] >News</option>
<option value="" [[!+fi.teamselect:FormItIsSelected=``]] >Events</option>
<option value="" [[!+fi.teamselect:FormItIsSelected=``]] >Web Content Update</option>
<option value="" [[!+fi.teamselect:FormItIsSelected=``]] >Web Tech Matters</option>
<option value="" [[!+fi.teamselect:FormItIsSelected=``]] >General Matters</option>

<label for="formQuery">Request [[!+fi.error.formQuery:notempty=`[[!+fi.error.formQuery]]`]]</label>
<textarea rows="5" cols="30" name="formQuery" id="formQuery" wrap="hard">[[!+fi.formQuery]]</textarea>

<input id="filedata" name="filedata" type="file" value="[[+fi.filedata]]">

<button type="submit">Send</button>
<input type="hidden" name="whatAreYouDoing" value="">
]]> Tue, 22 May 2018 03:04:12 +0000
<![CDATA[Bulk delete FormIt submissions]]> I have been making a form for a client. The submissions are saved using the the FormItSaveForm hook. When the client need the submission data, they go to the Extra/Formit menu and export a csv-file. They can remove/delete the submissions one by one.

I would like to make it possible to bulk delete these submission, but where do I start? Anyone who could point me in the right direction? An option for bulk deleting uploaded files in the mediabrowser would be nice too.

Best regards Gitte]]> Mon, 14 May 2018 09:28:25 +0000
<![CDATA["Form Select" dropdown in formit CMP]]>
The 'Form Select' dropdown list in the Formit CMP is empty, even though I have at least 5 different forms. I cannot select any. Should I enter some value for a variable in the systems settings?

Tnx for your help

]]> Thu, 03 May 2018 01:38:13 +0000
<![CDATA[Formit 4.0 - cannot have two forms on the same page]]>
Two forms on one and the same page. That should be no problem.

But do try the following code - and have it executed on a modx installation with formit 4.0.

[[!formit? &hooks=`redirect` &store=`1` &redirectTo=`90` &submitVar=`foo`]]

<form id="form1" action="[[~[[*id]]]]" method="post">
    <input type="submit" name="foo" class="btn btn-primary" value="Submit Inquiry">

<p>Something else</p>

[[!formit? &hooks=`redirect`  &store=`1` &redirectTo=`90` &submitVar=`bar`]]

<form id="form2" action="[[~[[*id]]]]" method="post">
    <input type="submit" name="bar" class="btn btn-primary" value="Submit Inquiry">

The first submit button executes the redirect. The second one doesn't do anything.

Is that a bug?

KInd regards

]]> Mon, 30 Apr 2018 05:48:54 +0000
<![CDATA[formit succes message]]>
I have an e-mail form which returns to the same page after sending.
I want to give the user a confirmation. Something basic, like "Your message has been send!" above the form.

I think I need to use hooks... but how? Can anybody help me? Thanks!]]> Wed, 11 Apr 2018 02:05:00 +0000