Statistics
2
1
0
62d
Badges
Tags
forms
Dependencies

hCaptcha

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

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>
  • 1.0.1

  • 1.0 Release 1.0

    Initial release.

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com