adair-creative/recaptcha

There is no license information available for the latest version (1.7) of this package.

Tools for quick Google ReCAPTCHA implementation

1.7 2021-09-17 20:09 UTC

This package is auto-updated.

Last update: 2024-05-18 02:18:08 UTC


README

About

Allows for easy and quick implementation of the Google ReCAPTCHA v2.0

Installation

composer require adair-creative/recaptcha

Guide

config.yml

AdairCreative\ReCAPTCHA:
    secret_key: [your-secret-key]
    app_key: [your-public-app-key]

PageController.php

protected function init() {
	...
	ReCAPTCHA::importJavascript();
	ReCAPTCHA::importCSS();
	...
}

YourForm.php

public function __construct(ContentController $controller, string $name) {
	$fields = new FieldList([
		TextField::create("Message", "")
	]);

	ReCAPTCHA::addField($fields);

	return parent::__construct(
		$controller,
		$name,
		$fields,
		new FieldList([]),
		new FieldList([
		"Message"
		])
	);
}