Search by

formatz / contao-recaptcha-bundle

formatz

Google reCAPTCHA v2 form field for Contao 5

Package info

gitlab.com/formatz/contao-recaptcha-bundle

Issues

Type:contao-bundle

pkg:composer/formatz/contao-recaptcha-bundle

Statistics

Installs: 51

Dependents: 0

Suggesters: 0

Stars: 0

2.0 2026-12-03 14:04 UTC

This package is auto-updated.

Last update: 2026-12-03 13:05:08 UTC


README

Google reCAPTCHA v2 ("I'm not a robot") form field for Contao 5.

Requirements

  • Contao 5.3 or newer
  • PHP 8.1 or newer (tested up to PHP 8.5)

Version 1.x of this bundle supports Contao 4.

Configuration

  1. Create a reCAPTCHA v2 "I'm not a robot" checkbox key pair in the Google reCAPTCHA admin console.
  2. In the Contao back end, go to System > Settings > reCaptcha configuration and enter the site key and the secret key.
  3. Add a reCaptcha I am not a robot field to your form.

The Google script is loaded only on pages that display the field. If your site sends a Content-Security-Policy, the field adds the Google reCAPTCHA sources to script-src and frame-src.

If the verification with Google cannot be done (missing secret key, network error), the form is not submitted and the error is written to the Contao system log. Google answers a wrong secret key like an invalid token, so a wrong key is not logged: if every submission is refused, check the keys first.

Upgrading from 1.x

  • The field template is now form_recaptcha (it extends form_row, like the core form fields). Rename any recaptcha.html5 override in your templates folder and adapt it.
  • The access key, tab index and add submit button options were removed, as in the Contao 5 core.
  • allow_url_fopen is no longer required when the PHP curl extension is available.
  • The widget class was renamed from Formatz\ContaoRecaptcha\FormReCaptcha to Formatz\ContaoRecaptchaBundle\Widget\Frontend\FormReCaptcha. Update any code that extends or references it.

For developers

The verification is done by the formatz_contao_recaptcha.verifier service (Formatz\ContaoRecaptchaBundle\Recaptcha\RecaptchaVerifier), which you can reuse or decorate. It uses the application's http_client service, so the HTTP client configuration of the project (proxy, etc.) applies.