vintage/yii2-invisible-recaptcha
最新稳定版本:v1.0.1
Composer 安装命令:
composer require vintage/yii2-invisible-recaptcha
包简介
Facade of Invisible reCAPTCHA by Google for Yii2 Framework
README 文档
README
Invisible reCAPTCHA
Facade of Invisible reCAPTCHA by Google for Yii2 Framework. For more info read official documentation.
Installation
Install package
Run command
$ composer require vintage/yii2-invisible-recaptcha
or add
"vintage/yii2-invisible-recaptcha": "~1.0"
to the require section of your composer.json.
Usage
-
Creates API key in your Google Account
-
Configure API keys in
frontend/config/params-local.php
<?php use vintage\recaptcha\helpers\RecaptchaConfig; return [ RecaptchaConfig::SITE_KEY => 'your_site_key', RecaptchaConfig::PRIVATE_KEY => 'your_private_key', ];
- Call widget in form
<form id="send-feedbacl-js" method="post">
<?= \vintage\recaptcha\widgets\InvisibleRecaptcha::widget([ 'formSelector' => '#send-feedback-js', ]) ?>
<button type="submit">Send</button> </form>
- Validate in backend
\vintage\recaptcha\validators\InvisibleRecaptchaValidator::validateInline( Yii::$app->getRequest()->post() );
or if you want to handle the errors
$validator = new \vintage\recaptcha\validators\InvisibleRecaptchaValidator( Yii::$app->getRequest()->post() ); if (!$validator->validate()) { return $validator->getErrors(); }
Configuration
Widget configuration options.
| Option | Description | Type | Default |
|---|---|---|---|
| options | Html options for recaptcha container | array | ['data-badge' => 'inline', 'data-size' => 'invisible'] |
| formSelector | Html form selector | string | 'form.invisible-recaptcha-js' |
| callback | Callback JS function. Calls after captcha was successfully passed | string | 'triggerReCaptcha' |
| siteKey | API site key | string | - |
License
This project is released under the terms of the BSD-3-Clause license.
Copyright (c) 2017, Vintage Web Production
统计信息
- 总下载量: 40.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 2
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-11-21