Recaptcha for Nette Framework 2.4+
parameters:
recaptcha:
sitekey: ...
secret: ...
Add extension method:
/**
* @param \Nette\Forms\Container
* @param string
* @param string
* @param string
* @return \App\UI\Forms\Controls\Recaptcha
*/
Container::extensionMethod('addRecaptcha', function (Container $form, $name = 'recaptcha', $caption = 'Recaptcha', $message = 'Recaptcha validation failed.') {
return $form[$name] = new App\UI\Forms\Controls\Recaptcha($caption, $message);
});
Add input in form
$form = new Form($this, $name); // form must be attached to presenter
$form->addRecaptcha();
Latte template
{input recaptcha}
HTML
...
<script src="https://www.google.com/recaptcha/api.js"></script>
</body>
</html>