We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31902
    • 342 Posts
    I've developed a form/recaptcha v2 issue on multiple sites after upgrading each to MODx 2.6.5. When someone submits a form, the page reloads to the form page again rather than redirecting to a thank you page. The reCaptcha V2 widget displays the "Please select the checkbox in the ReCaptcha image." error message.

    Although the submissions DOES go through, the error message fools the site visitor into attempting the form again, resulting in multiple submissions.

    The error log within the manager is filled with these submissions:

    [2018-08-20 15:17:16] (ERROR @ /home/username/public_html/core/components/formit/src/FormIt/Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.
    [2018-08-20 15:17:20] (ERROR @ /home/username/public_html/core/components/formit/src/FormIt/Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.
    [2018-08-20 15:17:20] (ERROR @ /home/username/public_html/core/components/formit/src/FormIt/Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.
    [2018-08-20 15:17:31] (ERROR @ /home/username/public_html/core/components/formit/src/FormIt/Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.


    1. I made sure I had the correct reCaptcha keys were set.
    2. I removed ReCaptchaV2 package completely and reinstalled. No good.
    3. Core/cache cleared.
    4. Reverted Formit back to the previous version (version 2.2.7-px) but that ended up crashing the entire front of the site...500 error. Luckily, the manager still worked since I was able to install the latest version of Formit back (version 4.1.0-pl), bringing the site back, but still not correcting the reCaptcha problem. BTW: after the crash, I saw this in the manager error log:

    [2018-08-20 15:15:03] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
    [2018-08-20 15:15:08] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
    [2018-08-20 15:15:15] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
    [2018-08-20 15:15:20] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
    [2018-08-20 15:15:24] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
    [2018-08-20 15:16:08] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
    [2018-08-20 15:16:18] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
    [2018-08-20 15:16:29] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.


    My form code, which was working before my upgrade(s), is this:

    [[!FormIt?  
    &hooks=`recaptchav2,spam,FormSave,email,emailUser-contact,redirect`
    &submitVar=`contact_page`
    &emailSubject=`Submission Through The Whatever Contact Page`
    &emailTpl=`contact_page_EmailChunk`
    &emailTo=`[email protected],[email protected]`
    &emailFrom=`[[+email-contact]]`
    &redirectTo=`10`
    &fsFormTopic=`Contact Page`
    &fsFormFields=`firstName-contact,lastName-contact,telephone-contact,email-contact,subject-contact,text-contact`
    ]]
    
    [[!+fi.error.error_message:notempty=`
    <p>[[!+fi.error.error_message]]</p>
    `]]
    
    
    
    
    
    <div class="col-md-12">
                                <form class="form" action="[[~[[*id]]]]" method="post" id="contactForm" >
    								<div class="row">
    									<div class="form-group">
    										<div class="col-md-6">
    											<label for="firstName-contact">First Name *
                                                <span class="error">[[+fi.error.firstName-contact]]</span></label>
    											<input type="text" value="[[+fi.firstName-contact]]" maxlength="100" class="form-control" name="firstName-contact" id="firstName-contact" required>
                                                <input name="nospam:blank" type="hidden" />
    										</div>
    										<div class="col-md-6">
    											<label for="lastName-contact">Last Name *<span class="error">[[+fi.error.lastName-contact]]</span></label>
    											<input type="text" value="[[+fi.lastName-contact]]" maxlength="100" class="form-control" name="lastName-contact" id="lastName-contact" required>
    										</div>
    									</div>
    								</div>
                                    
    								<div class="row">
    									<div class="form-group">
    										<div class="col-md-6">
    											<label for="email-contact">Email *
                                                <span class="error">[[+fi.error.email-contact]]</span></label>
    											<input type="text" value="[[+fi.email-contact]]" maxlength="100" class="form-control" name="email-contact" id="email-contact" required>
    										</div>
    										<div class="col-md-6">
    											<label for="telephone-contact">Telephone *<span class="error">[[+fi.error.telephone-contact]]</span></label>
    											<input type="text" value="[[+fi.telephone-contact]]" maxlength="100" class="form-control" name="telephone-contact" id="telephone-contact" required>
    										</div>
    									</div>
    								</div>
    
                                    
    								<div class="row">
    									<div class="form-group">
    										<div class="col-md-12">
    											<label for="subject-contact">Subject</label>
    											<input type="text" value="[[+fi.subject-contact]]" maxlength="100" class="form-control" name="subject-contact" id="subject-contact">
    										</div>
    									</div>
    								</div>
    								<div class="row">
    									<div class="form-group">
    										<div class="col-md-12">
    											<label for="text-contact">Message</label>
    											<textarea maxlength="5000" rows="10" class="form-control" name="text-contact" id="text-contact">[[+fi.text-contact]]</textarea>
    										</div>
    									</div>
    								</div>
    								<div class="row">
    									<div class="form-group">
    										<div class="col-md-12">
     											
    [[!recaptchav2_render]]<span style="color: #ff0000; font-size: 1.2em; font-weight: bold;">[[!+fi.error.recaptchav2_error]]</span>
    
    										</div>
    									</div>
    								</div>
    								<div class="row">
    									<div class="col-md-12">
                                                                                    <input type="hidden" name="subject" id="subject" value="Submission Through The Whatever Website Contact Page" />
    										<input type="submit" value="Submit" class="btn btn-primary btn-lg" name="contact_page" >
    									</div>
    								</div>
    							</form>
    						</div>
    <div style="clear: both;"></div>


    This same issue is happening on several sites. Any thoughts would be appreciated.

    MODx 2.6.5
    PHP 7.0
    FormIt 4.1.0-pl
    ReCaptchaV2 2.3.0-rc1

    This question has been answered by waizen. See the first response.

    [ed. note: waizen last edited this post 5 years, 7 months ago.]
      • 3749
      • 24,544 Posts
      On the original error, there should be a property called &modelPath in the FormIt tag (or the FormIt snippet properties).

      My wild guess is that the property is missing or has an incorrect value.

      I believe it's supposed to hold the path to core/components/formit/model/
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 31902
        • 342 Posts
        Quote from: BobRay at Aug 20, 2018, 10:44 PM
        On the original error, there should be a property called &modelPath in the FormIt tag (or the FormIt snippet properties).

        My wild guess is that the property is missing or has an incorrect value.

        I believe it's supposed to hold the path to core/components/formit/model/

        Forgive my ignorance, Bob, but is there anything I can do to correct this? This is happening on multiple sites. The sites had been working okay before the upgrades.
          • 3749
          • 24,544 Posts
          See if there is a &modelPath property in the FormIt snippet tag. If so, is the path accurate?

          If not, add one with the correct path to the FormIt model directory.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 31902
            • 342 Posts
            I'm sorry, Bob. I'm not following what you mean. As I understand it, my Formit snippet tag, as shown in my first post above, looks like this:


            [[!FormIt?  
            &hooks=`recaptchav2,spam,FormSave,email,emailUser-contact,redirect`
            &submitVar=`contact_page`
            &emailSubject=`Submission Through The Whatever Contact Page`
            &emailTpl=`contact_page_EmailChunk`
            &emailTo=`[email protected],[email protected]`
            &emailFrom=`[[+email-contact]]`
            &redirectTo=`10`
            &fsFormTopic=`Contact Page`
            &fsFormFields=`firstName-contact,lastName-contact,telephone-contact,email-contact,subject-contact,text-contact`
            ]]


            Is that where you're referring to? This was after an upgrade to 2.6.5 so nothing should have changed; it was working before.
              • 3749
              • 24,544 Posts
              I was going by this code in version 4.1.0 of FormIt:

              $modelPath = $modx->getOption(
                  'formit.core_path',
                  null,
                  $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/formit/'
              ) . 'model/formit/';
              $modx->loadClass('FormIt', $modelPath, true, true);


              and your error message saying that it couldn't find the formit class file.

              I was wrong about the property name, though. It would be 'formit.core_path', but it would default to core/components/formit/model/formit/. You could look to see if the formit.class.php file is at that location.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 31902
                • 342 Posts
                Quote from: BobRay at Aug 27, 2018, 09:03 PM
                ...You could look to see if the formit.class.php file is at that location.

                Yes, it is.
                  • 31902
                  • 342 Posts
                  So frustrating. Apparently others have had this issue as well but no good solution, as I can see.

                  Are there any other good captcha solutions out there? I know that there is this:

                  https://modx.com/extras/package/captcha 


                  ...but that is apparently for the login page form. Bob, you hint that it can be somehow converted for use in front end forms? Can you provide detailed instructions as to how that can be done?

                  Other than that, does anyone know of any other captcha systems for MODx?
                  • discuss.answer
                    • 31902
                    • 342 Posts
                    Looks like I've fixed the issue.

                    Again, using the error message to find any more solutions online, I came across this page (translated):

                    https://github.com/Sterc/FormIt/issues/170&xid=25657,15700019,15700124,15700149,15700186,15700191,15700201&usg=ALkJrhgbXX4vIBd6gAJrFcw8-6NuGT1NdQ" target="_blank" rel="nofollow">https://translate.googleusercontent.com/translate_c?depth=1&hl=en&prev=search&rurl=translate.google.com&sl=ru&sp=nmt4&u=https://github.com/Sterc/FormIt/issues/170&xid=25657,15700019,15700124,15700149,15700186,15700191,15700201&usg=ALkJrhgbXX4vIBd6gAJrFcw8-6NuGT1NdQ

                    I utilized the solution offered by Andres-M-Rios on that page. At that point, my original repeating error:

                    [2018-08-20 15:17:31] (ERROR @ /home/username/public_html/core/components/formit/src/FormIt/Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.


                    ...in the MODx manager went away but replaced with another one:

                    [2018-08-30 13:44:46] (ERROR @ /home/username/public_html/core/cache/includes/elements/modsnippet/20.include.cache.php : 29) An error occurred while trying to send the email: 


                    Looking inside that cache file, I recognized the contents as the template I created a long time ago as a thank you message to the form visitor. So, as a hunch, I took out the "emailUser-contact" entry from the &hooks=`recaptchav2,spam,FormSave,email,emailUser-contact,redirect` hook chain.

                    That apparently fixed it. I'll monitor this for for a few days to make sure the fix has taken before employing it on the other sites I'm having the same issue with. Thank you, Bob, for all your help. I's been greatly appreciated!