This version is suitable for Nette 2.4.
composer require minetro/recaptcha:~2.1.1
extensions:
recaptcha: Minetro\ReCaptcha\DI\ReCaptchaExtension
recaptcha:
secretKey: ***
siteKey: ***
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());
}
}
<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>