Recaptcha on SS3.6

SS3.6

Trying to get silverstripe-recaptcha working on a form. I have installed it as laid out in the ReadMe on GitHub, but it doesn’t seem to do anything. It breaks the form and doesn’t seem to call the Submit handler function.

I have not added any javascript code.
I have done a dev/build?flush

In the form code:

		$form = Form::create ($this, 'JoinForm', $fields, $actions, $required);
		$form->enableSpamProtection([
			'protector' => 'RecaptchaProtector',
			'name' => 'Captcha'
		]);

recaptcha.yml:

---
Name: recaptcha
---
FormSpamProtectionExtension:
  default_spam_protector: RecaptchaProtector
  
RecaptchaField:
  public_api_key: "xxx"
  private_api_key: "xxx"

I know it’s been a long time since you posted but did you solve the issue in the end? I’ve got Recaptcha working by installing both “spamprotection” and “nocaptcha”. And yes, it initially breaks the form after you’ve added a spamprotection field there, but then you set up the recaptcha key with Google and edit the relevant yml file with the following:

UndefinedOffset\NoCaptcha\Forms\NocaptchaField:
site_key: “SITE KEY GOES HERE” #Your site key (required)
secret_key: “SECRET KEY GOES HERE” #Your secret key (required)
recaptcha_version: 2 # 2 or 3
minimum_score: 0.2 # minimum spam score to achieve. Any less is blocked
verify_ssl: true #Allows you to disable php-curl’s SSL peer verification by setting this to false (optional, defaults to true)
default_theme: “light” #Default theme color (optional, light or dark, defaults to light)
default_type: “image” #Default captcha type (optional, image or audio, defaults to image)
default_size: “normal” #Default size (optional, normal, compact or invisible, defaults to normal)
default_badge: “bottomright” #Default badge position (bottomright, bottomleft or inline, defaults to bottomright)
proxy_server: “” #Your proxy server address (optional)
proxy_port: “” #Your proxy server address port (optional)
proxy_auth: “” #Your proxy server authentication information (optional)

The following options can also be specified through Environment variables with Injector config

SilverStripe\Core\Injector\Injector:
UndefinedOffset\NoCaptcha\Forms\NocaptchaField:
properties:
SiteKey: ‘SITE KEY GOES HERE’ # SS_NOCAPTCHA_SITE_KEY
SecretKey: ‘SECRET KEY GOES HERE’ # SS_NOCAPTCHA_SECRET_KEY
ProxyServer: ‘SS_OUTBOUND_PROXY
ProxyPort: ‘SS_OUTBOUND_PROXY_PORT
ProxyAuth: ‘SS_OUTBOUND_PROXY_AUTH

Don’t forget to rebuild and flush afterwards