CGBetterForms / Captcha - recapture div

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
cjcollen
Forum Members
Forum Members
Posts: 36
Joined: Sat Aug 04, 2018 4:20 pm
Location: Shropshire, UK

CGBetterForms / Captcha - recapture div

Post by cjcollen »

I am using CGBetterForms with Captcha for my contact form.
I am using the recapture option for Captcha. I have my site key etc. But I cannot see how to add the 'data-size="compact"' attribute to the div that is subsequently generated.

I want the captcha div to be
<div class="g-recaptcha" data-sitekey="mysitekey" data-size="compact"></div>

but it is coming out as
<div class="g-recaptcha" data-sitekey="mysitekey"></div>

I do not want to change the source code in Captcha/plugins/recaptcha/cm_plugin.recaptcha.php which is where I think the code is coming from.

I tried copying this code to assets/module_custom/Captcha/plugins/recaptcha/cm_plugin.recaptcha.php and changing it there but it was ignored by CMSMS.

The reason for wanting to add this attribute is to make the Captcha thingy on the rendered form display better on small devices.

Any assistance appreciated. I am sure it is easy to do but cannot see wood for those pesky trees :)

BTW am loving the CGBetterForms and CMSMS version 2
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1609
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: CGBetterForms / Captcha - recapture div

Post by DIGI3 »

Probably would need an option added to the Captcha module, which you may be able to have added by filing a feature request.

A workaround may be to just add it via jQuery:

Code: Select all

$('.g-recaptcha').attr('data-size', 'compact');
(not tested)
Not getting the answer you need? CMSMS support options
cjcollen
Forum Members
Forum Members
Posts: 36
Joined: Sat Aug 04, 2018 4:20 pm
Location: Shropshire, UK

Re: CGBetterForms / Captcha - recapture div

Post by cjcollen »

Thanks for speedy response, Digi3.

I will try out that jQuery option and look into filing a feature request.
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1609
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: CGBetterForms / Captcha - recapture div

Post by DIGI3 »

Might have to get creative with redrawing the captcha after the data-attribute is added, but it's a starting point anyway.

If you did want to try the module_custom template method again, make sure you clear the cache after. Also, if it doesn't work in assets/module_custom/captcha/templates/, try just in /module_custom/captcha/templates/ (some modules seem to need the old method in order to work)
Not getting the answer you need? CMSMS support options
cjcollen
Forum Members
Forum Members
Posts: 36
Joined: Sat Aug 04, 2018 4:20 pm
Location: Shropshire, UK

Re: [SOLVED]CGBetterForms / Captcha - recapture div

Post by cjcollen »

Implemented the jQuery solution mentioned above. It was easy and simple to do and it worked.

I will also try your suggestion of putting the change in module_custom/captcha/templates and see if that also gives me what I want.

Thank you, Digi3
Post Reply

Return to “Modules/Add-Ons”