vottuscode / hcaptcha
This package is abandoned and no longer maintained.
No replacement package was suggested.
hCaptcha for Nette Forms
1.0.1
2020-05-18 15:43 UTC
Requires
- php: ^7.2
- nette/di: ~3.0.0
- nette/forms: ~3.0.0
- nette/utils: ~3.0.0|~3.1.0
Requires (Dev)
- ninjify/nunjuck: ^0.3.0
- ninjify/qa: ^0.9.0
- phpstan/phpstan-deprecation-rules: ^0.11
- phpstan/phpstan-nette: ^0.11
- phpstan/phpstan-shim: ^0.11
- phpstan/phpstan-strict-rules: ^0.11
Suggests
- ext-openssl: To make requests via https
This package is auto-updated.
Last update: 2020-09-12 12:16:43 UTC
README
hCaptcha implementation for Nette Framework forms.
Forked from contributte/reCAPTCHA
Pre-installation
Add your site to the site list in the hCaptcha dashboard.
hCaptcha in action
Installation
The latest version is most suitable for Nette 3.0 and PHP >=7.1.
composer require vottuscode/hcaptcha
Configuration
extensions: recaptcha: Contributte\ReCaptcha\DI\ReCaptchaExtension recaptcha: secretKey: "your_hcaptcha_secret_key" siteKey: your_hcaptcha_site_key
(Be sure to include quotes for the secretKey)
Usage
(It is the same as hCaptcha, there is no change whatsoever in classes to prevent BC breaks )
use Nette\Application\UI\Form; protected function createComponentForm() { $form = new Form(); $form->addReCaptcha('hcaptcha', $label = 'Captcha') ->setMessage('Are you a bot?'); $form->addReCaptcha('hcaptcha', $label = 'Captcha', $required = FALSE) ->setMessage('Are you a bot?'); $form->addReCaptcha('hcaptcha', $label = 'Captcha', $required = TRUE, $message = 'Are you a bot?'); $form->onSuccess[] = function($form) { Debugger::barDump($form->getValues()); }; }
Rendering
<form n:name="myForm"> <div class="form-group"> <div n:name="recaptcha"></div> </div> </form>
Be sure to place this script before the closing tag of the body
element (</body>
).
<!-- re-Captcha --> <script src="https://hcaptcha.com/1/api.js" async defer></script>