#1 November 9, 2017 2:42pm

doon.mok
Member
Registered: May 6, 2015
Posts: 141

Form Builder reCaptcha not working

Hello,

I added the reCaptcha field to a form but when I go to the form, all I get is the text

Spam Prevention    *
Please help us prevent spam by using the reCAPTCHA below.

I added the site key and secret key in the settings.
When I inspect the field, the data-sitekey is empty and in the console, it is showing an error: Uncaught Error: Missing required parameters: sitekey

Is there something else I need to do to make it work?

Thanks

Doon

Offline

#2 November 9, 2017 2:45pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Form Builder reCaptcha not working

If you have a custom Form Builder template (for drawing on the front end) you may need to modify the call to get the setting to explicitly ask for the extension version.

Modify this line (in _header.php in the template):

$settings = $cms->getSetting("settings");

to

$settings = $cms->getSetting("com.fastspot.form-builder*settings");

Offline

#3 November 9, 2017 2:53pm

doon.mok
Member
Registered: May 6, 2015
Posts: 141

Re: Form Builder reCaptcha not working

Thanks Tim!! That fixed the issue.

Doon

Offline

#4 April 18, 2018 9:00am

mke18
Member
Registered: April 18, 2018
Posts: 28

Re: Form Builder reCaptcha not working

Hi Tim,

I have the similar issue with reCaptcha and I checked the _header.php in the template folder but I couldn't find it. Would  you point me where is this file. I found two _header.php files, one in /core/admin/layouts/ and the other in /templates/routed/directory/. Both of those files don't show the line of code that should be modified as you mentioned above.

Would you point me to the right folder or a path to the file?

Thanks,

Offline

#5 April 18, 2018 9:12am

jmason03
Member
Registered: January 9, 2014
Posts: 123

Re: Form Builder reCaptcha not working

The correct _header.php file should be located in this location: extensions/com.fastspot.form-builder/templates/routed/btx-form-builder/

The one in /core/admin/layouts/ is for the header in the BigTree admin.

The one in /templates/routed/directory/ is for the header of your "Directory" template.

Offline

#6 April 18, 2018 9:16am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Form Builder reCaptcha not working

If you're using the extension version, jmason03 is correct about the location of the _header.php file in question.
If you're using a custom form builder template (e.g. there's something like /btx-form-builder/ inside of /templates/routed/) then you'll want to look in /templates/routed/btx-form-builder/ and make the getSetting adjustment I mentioned on November 9th.

The reason for this is that when in extension context (loading a template from the /extensions/ directory) BigTree does extension ID inference on calls to getSetting. That allows you to use getSetting("my-setting") within your extension and automatically reference the setting included by your extension. When the template is copied outside of the /extensions/ directory it can no longer do the ID inference and it needs an explicit extension namespace applied to the getSetting call (in this case, the namespace is com.fastspot.form-builder).

Offline

#7 April 18, 2018 12:03pm

mke18
Member
Registered: April 18, 2018
Posts: 28

Re: Form Builder reCaptcha not working

Thanks, I found it!

Here's the edited line:
    //$settings = $cms->getSetting("settings"); KE NNA FELA
    $settings = $cms->getSetting("com.fastspot.form-builder*settings");

But still the reCaptcha doesn't work. Please, see the screenshot link below.

https://pasteboard.co/Hhdalyd.png

Last edited by mke18 (April 18, 2018 12:05pm)

Offline

#8 April 18, 2018 12:05pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Form Builder reCaptcha not working

What do you get when you var_dump $settings?

Offline

#9 April 18, 2018 12:22pm

mke18
Member
Registered: April 18, 2018
Posts: 28

Re: Form Builder reCaptcha not working

I don't seem to see anything unless I'm doing something wrong. Also, this is what I see on the Console:

     Uncaught Error: Missing required parameters: sitekey
    at new Tq (VM3395 recaptcha__en.js:378)
    at new tr (VM3395 recaptcha__en.js:386)
    at Gr (VM3395 recaptcha__en.js:398)
    at VM3395 recaptcha__en.js:398

Offline

#10 April 18, 2018 12:23pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Form Builder reCaptcha not working

var_dump should show something like "null" even if the setting is empty, but if it has content it should have a bunch of text output.

Offline

#11 April 18, 2018 12:26pm

mke18
Member
Registered: April 18, 2018
Posts: 28

Re: Form Builder reCaptcha not working

So, I put the var_dump below this $settings = $cms->getSetting("com.fastspot.form-builder*settings");

Offline

#12 April 18, 2018 12:38pm

mke18
Member
Registered: April 18, 2018
Posts: 28

Re: Form Builder reCaptcha not working

When I add the var_dump on the head.php, I get bool(false).

Offline

#13 April 18, 2018 12:50pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Form Builder reCaptcha not working

A "false" response means that the requested setting is not in the database.

Offline

#14 April 18, 2018 5:26pm

mke18
Member
Registered: April 18, 2018
Posts: 28

Re: Form Builder reCaptcha not working

Here's the var_dump results:

array(4) { [0]=> string(0) "" ["accept_payments"]=> string(0) "" ["no_css"]=> string(0) "" ["recaptcha"]=> array(2) { ["site_key"]=> string(40) "" ["secret_key"]=> string(40) "" } }

Offline

#15 April 18, 2018 7:59pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Form Builder reCaptcha not working

That result looks like a properly returning settings array. The next step would be to try to figure out why the draw file for the captcha isn't reading $settings properly.

Offline

#16 April 19, 2018 1:11pm

mke18
Member
Registered: April 18, 2018
Posts: 28

Re: Form Builder reCaptcha not working

Tim,

When I take off the reCapture form element, I don't see the error on the  Console like below:
Uncaught Error: Missing required parameters: sitekey
    at new Tq (VM3395 recaptcha__en.js:378)
    at new tr (VM3395 recaptcha__en.js:386)
    at Gr (VM3395 recaptcha__en.js:398)
    at VM3395 recaptcha__en.js:398

So, could this be the js conflicts?

Offline

#17 April 20, 2018 9:52am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Form Builder reCaptcha not working

It is unlikely to be a Javascript conflict. The Javascript error is reporting that the sitekey is missing, so it is likely that the data-sitekey attribute of the reCAPTCHA container is not drawing properly.

Offline

#18 April 20, 2018 12:03pm

mke18
Member
Registered: April 18, 2018
Posts: 28

Re: Form Builder reCaptcha not working

How can we fix this? Is there's something to be done here on the draw/captcha:
    <label>
        <?=htmlspecialchars($field_data["label"])?>
        <span class="form_builder_required_star">*</span>
    </label>
    <?php
        }
       
        if ($field_data["instructions"]) {
    ?>
    <p><?=htmlspecialchars($field_data["instructions"])?></p>
    <p><?=htmlspecialchars($field_data["recaptcha"])?></p>

Offline

#19 April 20, 2018 12:22pm

mke18
Member
Registered: April 18, 2018
Posts: 28

Re: Form Builder reCaptcha not working

What I don't get is that, when I add this: <div class="g-recaptcha" data-sitekey="with-my-site-key">&nbsp;</div> on the WYSIWYG and reCaptcha image appear and works (meaning I can click and verify). However, it doesn't work on the form builder element.

See here:
https://pasteboard.co/Hhw7RxB.png
https://pasteboard.co/Hhw82QD.png
https://pasteboard.co/Hhw87i4.png

Offline

#20 April 23, 2018 2:12pm

doon.mok
Member
Registered: May 6, 2015
Posts: 141

Re: Form Builder reCaptcha not working

Hello,

It looks like it is getting your site key in var_dump of $settings. Can you confirm your draw/captatcha.php file data-sitekey has the echo below?

data-sitekey="<?=$settings["recaptcha"]["site_key"]?>"

If it does, can you try removing <?=$settings["recaptcha"]["site_key"]?> and just entering your site key and see if that shows up on the form?

Last edited by doon.mok (April 23, 2018 2:15pm)

Offline

#21 April 24, 2018 10:37am

mke18
Member
Registered: April 18, 2018
Posts: 28

Re: Form Builder reCaptcha not working

Morning!

Thanks for your suggestion. Yes, I did made the edits and now the reCaptcha shows up but it keeps giving an error saying: "The code you entered was not correct. Please try again." Also showing that I'm missing a required field but I have four field and they are not required fields at all.

Offline

#22 April 24, 2018 10:51am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Form Builder reCaptcha not working

You'll also want to update the /process/captcha.php file to include your secret key if it's not loading through the setting.

Offline

#23 April 24, 2018 2:13pm

mke18
Member
Registered: April 18, 2018
Posts: 28

Re: Form Builder reCaptcha not working

Thanks everyone!

Made those changes on /process/captcha.php and it seems to be working and I can preview the form entries.

Thanks!

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.