Skip to content

Latest commit

 

History

History
60 lines (43 loc) · 1.02 KB

README-2.x.md

File metadata and controls

60 lines (43 loc) · 1.02 KB

reCAPTCHA 2.x

Installation

This version is suitable for Nette 2.4.

composer require minetro/recaptcha:~2.1.1

Configuration

extensions:
	recaptcha: Minetro\ReCaptcha\DI\ReCaptchaExtension

recaptcha:
	secretKey: ***
	siteKey: ***

Usage

use Nette\Application\UI\Form;

protected function createComponentForm()
{
	$form = new Form();

	$form->addReCaptcha('recaptcha', $label = 'Captcha')
		->setMessage('Are you bot?');

	$form->addReCaptcha('recaptcha', $label = 'Captcha', $required = FALSE)
		->setMessage('Are you bot?');

	$form->addReCaptcha('recaptcha', $label = 'Captcha', $required = TRUE, $message = 'Are you bot?');

	$form->onSuccess[] = function($form) {
		dump($form->getValues());
	}
}

Rendering

<form n:name="myForm">
    <div class="form-group">
        <div n:name="recaptcha"></div>
    </div>
</form>

Be sure you place this script before </body> element.

<!-- re-Captcha -->
<script src='https://www.google.com/recaptcha/api.js'></script>