承接 luyadev/yii2-recaptcha-widget 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

luyadev/yii2-recaptcha-widget

最新稳定版本:1.0.0

Composer 安装命令:

composer require luyadev/yii2-recaptcha-widget

包简介

Yii2 Google reCAPTCHA v2 and v3 widget

README 文档

README

LUYA Logo

Google reCAPTCHA widget

THIS IS A FORK FROM THE ARCHIVED HIMIKLAB REPOSITORY. THE MAIN GOAL IS TO SUPPORT LATEST PHP VERSIONS

Tests Total Downloads

Installation

composer require luyadev/yii2-recaptcha-widget

Sign up for an reCAPTCHA API keys and configure the component in your configuration file.

'components' => [
    'reCaptcha' => [
        'class' => 'luyadev\recaptcha\ReCaptchaConfig',
        'siteKeyV2' => 'your siteKey v2',
        'secretV2' => 'your secret key v2',
        'siteKeyV3' => 'your siteKey v3',
        'secretV3' => 'your secret key v3',
    ],
    ...

Add ReCaptchaValidator2 or ReCaptchaValidator3 as validator into your model, do not forget to set those attributes as required.

public $reCaptcha;

public function rules()
{
    return [
        [['reCaptcha'], 'required'],
        [['reCaptcha'], \luyadev\recaptcha\ReCaptchaValidator2::class, 'uncheckedMessage' => 'Please confirm that you are not a bot.'],
    ];
}
public $reCaptcha;

public function rules()
{
    return [
        [['reCaptcha'], 'required'],
        [['reCaptcha'], \luyadev\recaptcha\ReCaptchaValidator3::class, 'threshold' => 0.5, 'action' => 'homepage'],
    ];
}

Usage in the view files for ActiveForm:

NOTE: Disable ajax validation for ReCaptcha field!

$form->field($model, 'reCaptcha')->widget(\luyadev\recaptcha\ReCaptcha2::class) // v2
$form->field($model, 'reCaptcha')->widget(\luyadev\recaptcha\ReCaptcha3::class, ['action' => 'homepage']) // v3

as widgets:

\luyadev\recaptcha\ReCaptcha2::widget([
    'name' => 'reCaptcha',
    'widgetOptions' => ['class' => 'col-sm-offset-3'],
]);

v3

\luyadev\recaptcha\ReCaptcha3::widget([
    'name' => 'reCaptcha',
    'action' => 'homepage',
    'widgetOptions' => ['class' => 'col-sm-offset-3'],
]);

统计信息

  • 总下载量: 13.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 108
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-16