Skip to content

‼️ Google reCAPTCHA (security) for Nette Framework \ Forms

License

Notifications You must be signed in to change notification settings

hubnedav/reCAPTCHA

 
 

Repository files navigation

reCAPTCHA

Google reCAPTCHA implementation for Nette Framework forms.


Build Status Code coverage Licence

Downloads this Month Downloads total Latest stable

Discussion / Help

Join the chat

Versions

Branch Composer Nette PHP Readme
latest ~3.0.0 2.4 >=5.6 -
2.x ~2.1.0 2.4 >=5.6 README-2.x
1.6.x ~1.6.3 2.4 >=5.6 README-1.6
1.5.x ~1.5.2 2.3 >=5.4 README-1.5
1.4.x ~1.4.4 2.2 >=5.4 README-1.4
1.3.x ~1.3.0 2.1 >=5.4 README-1.3

Pre-installation

Add your site to the sitelist in reCAPTCHA administration.

reCAPTCHA

Installation

The latest version is most suitable for Nette 2.4 and PHP >=5.6.

composer require contributte/recaptcha:~2.1.0

Configuration

extensions:
    recaptcha: Contributte\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>

About

‼️ Google reCAPTCHA (security) for Nette Framework \ Forms

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%