xstreamka/yii2-recaptcha-widget
最新稳定版本:v1.1
Composer 安装命令:
composer require xstreamka/yii2-recaptcha-widget
包简介
Spam check widget for Yii2, based on Google reCAPTCHA API v3
README 文档
README
Spam check widget for Yii2, based on Google reCAPTCHA API v3.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist xstreamka/yii2-recaptcha-widget "*"
or add
"xstreamka/yii2-recaptcha-widget": "*"
to the require section of your composer.json file.
Further:
- Sign up for an reCAPTCHA API keys.
- Configure the component in your configuration file (
frontend/config/main.php):
'components' => [ ... 'reCaptcha' => [ 'class' => 'xstreamka\recaptcha\ReCaptchaConfig', 'siteKeyV3' => 'your siteKey v3', 'secretV3' => 'your secret key v3', ], ... ]
Usage
Once the extension is installed, simply use it in your code by:
<?php $form = ActiveForm::begin(); ?> ... <?= \xstreamka\recaptcha\ReCaptcha::widget(); // added hidden input ?> ... <?php ActiveForm::end(); ?>
this will add a hidden field to your form.
Validate
For form validation use:
<?= \xstreamka\recaptcha\ReCaptcha::validate(); ?>
this is called after POST request.
Example
$model = new QuestionForm(); if ($model->load(Yii::$app->request->post()) && $model->validate() && \xstreamka\recaptcha\ReCaptcha::validate()) { ... }
统计信息
- 总下载量: 7.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-25