We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49312
    • 61 Posts
    I have tried adding RecaptchaV2 to a client's website. It will render and I can check the box, but when I submit the form it fails and just reloads the page instead of taking me to my success message.

    I get this error: (ERROR @ C:\inetpub\sites\dev.parksideinc_2016\core\components\formit\src\FormIt\Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.

    Digging further into the FormIt code, it seems to be an issue in the base code of FormIt itself. Its trying to load the default recaptcha classes because of the way it checks for the "hooks". If you try to use any hook with 'recaptcha' anywhere in the name, it will try to load the default version of recaptcha and thats whats causing it to fail.

    Formit and Recaptcha are both up to date. Anyone ran into this issue before?

    Thanks,
    Steve
      • 54244
      • 2 Posts
      andymancan4 Reply #2, 6 years ago
      Quote from: formulax at May 07, 2018, 07:40 PM
      I have tried adding RecaptchaV2 to a client's website. It will render and I can check the box, but when I submit the form it fails and just reloads the page instead of taking me to my success message.

      I get this error: (ERROR @ C:\inetpub\sites\dev.parksideinc_2016\core\components\formit\src\FormIt\Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.

      Digging further into the FormIt code, it seems to be an issue in the base code of FormIt itself. Its trying to load the default recaptcha classes because of the way it checks for the "hooks". If you try to use any hook with 'recaptcha' anywhere in the name, it will try to load the default version of recaptcha and thats whats causing it to fail.

      Formit and Recaptcha are both up to date. Anyone ran into this issue before?

      Thanks,
      Steve

      Steve,

      I am having the exact same problem, just started using Modx so am not as experienced and could not nail down what was going on, but it sounds like I'm having the exact same issue! Latest update of FormIt must have had some negative effect on recaptchav2 functionality using other plugins would be my guess. I think I'm gonna start digging into the plugin code later.

      My post is here: https://forums.modx.com/thread/?thread=103831#dis-post-558424

      I'm going to subscribe to your post as well, any answers either of us gets should help us out (and others with same problems I'm sure are many.)

      Hoping we get some replies!

      Andy
        • 46886
        • 1,154 Posts
        Anything in the error log?

        I believe I have dealt with this issue some time ago, you have to change templates in your Formit chunks I believe. Otherwise it will use the default tpl chunk.

        Ah, here it is, its a different issue but you might find something useful

        https://forums.modx.com/thread/99538/recaptcha-v2-how-to-change-it-s-theme

        and this looks possibly useful but its Evo which means the internal code we have to use changes a bit.

        https://forums.modx.com/thread/99706/eform---recaptcha-verification-anti-spam?page=2#dis-post-539342

        Is this really a new issue meaning you could roll back or not update Formit?

        We have to figure out where the problem lies, its possible I believe to put error triggers for each step of the form, so you may be able to know
          • 42042
          • 140 Posts
          Any progress on this topic? Still getting: Could not load FormItReCaptcha service class. Trying to poke around in the code, but no luck so far.
          • Quote from: formulax at May 07, 2018, 07:40 PM

            I get this error: (ERROR @ C:\inetpub\sites\dev.parksideinc_2016\core\components\formit\src\FormIt\Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.

            Because FormIt wrongly evaluate the "hooks":

            FormIt->hasHook($hookname) -> return strpos($hooks,$hookname)


            So, if we have [[!FormIt? &hooks=`precaptchas,recaptchaNew,NewRecaptcha`]] it will make FormIt generate the error. I think using strpos to evaluate the hookname is kinda weird.
              zaenal.lokamaya
            • I propose the change on GitHub (https://github.com/Sterc/FormIt/pull/181).

              Or you can manually replace return strpos($this->config['hooks'],$hook) !== false; with the code below (see the attachment).

              
                   public function hasHook($hook) {
                      return !!preg_match('#\\b' . preg_quote($hook, '#') . '\\b#i', $this->config['hooks']);
                   }
              
              


              On MODx installation, the file is located at /core/components/formit/src/FormIt.php
              [ed. note: lokamaya last edited this post 5 years, 9 months ago.]
                zaenal.lokamaya
                • 3749
                • 24,544 Posts
                I think using strpos to evaluate the hookname is kinda weird

                Using strpos() is pretty common because it's faster than substr() and *way* faster then using a regular expression. It does mean that the hook name has to be spelled exactly the same way everywhere, though.
                  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