lg-xenos / yii2-recaptcha
Yii2 组件-小部件 Google recaptcha
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-09-13 20:45:57 UTC
README
带有 Google Recaptcha 的 Yii2 组件-小部件。Ajaxed。Multipled。Fixed
composer require lg-xenos/yii2-recaptcha
'components' => [ 'reCaptcha' => [ 'name' => 'reCaptcha', 'class' => 'lgxenos\yii2\recaptcha\ReCaptcha', // Get reCAPTCHA API keys: https://www.google.com/recaptcha/admin#createsite 'siteKey' => 'your siteKey', 'secret' => 'your secret key', ], ...
- 规则/rules 对于 ActiveRecordModel / ActiveFormAdd
public $reCaptcha; public function rules() { return [ // ... [[], \lgxenos\yii2\recaptcha\ReCaptchaValidator::className(), 'uncheckedMessage' => 'Please confirm that you are not a bot.'] ]; }
- {view}.php
<?= $form->field($model, 'reCaptcha')->widget(\lgxenos\yii2\recaptcha\ReCaptcha::className()) ?>
多个 reCaptcha / 在一页上多个 reCaptcha
每个都有自己的 ID / 每个 reCaptcha 实例都必须有唯一的 ID
<?= $form1->field($modelForm1, 'reCaptcha') ->widget(\lgxenos\yii2\recaptcha\ReCaptcha::className(), [ 'widgetOptions' => [ 'id' => 'form-ONE', ] ]) ?> <?= $form2->field($modelForm2, 'reCaptcha') ->widget(\lgxenos\yii2\recaptcha\ReCaptcha::className(), [ 'widgetOptions' => [ 'id' => 'form-TWO', ] ]) ?>
阅读材料 / 资源
-
. . .
一些历史 / 一些历史
(以下为英文)
背景是这样的,himiklab 为 Google reCAPTCHA 创建了一个小部件基础。但它不适用于 Ajax。有人向他 [提出 PR] (himiklab/yii2-recaptcha-widget#23),但长时间处于“冲突”状态,从未实现。
现在那里有其他问题,再次提出了解决该问题的建议。但遗憾的是,作者正在等待 PR。
在我 [一个问题] (https://github.com/himiklab/yii2-recaptcha-widget/issues/57) 上,他写道:“我欠某人什么?”当然,然后它被删除了。但我收到了带有这条消息的电子邮件。
当然不是。但我们也不欠你。但写:“抱歉我太忙了,在 <...> 查找错误” - 这是最佳实践。使用它。
此代码基于 himiklab 和 den67rus 的努力,然后“用锤子加工”。
英文 - 我只使用 Google 翻译,因为我对它不是很了解
背景是 himiklab 为 google-recaptcha 创建了一个小部件基础。但它不适用于 Ajax。有人向他 [提出 PR] (himiklab/yii2-recaptcha-widget#23),但长时间处于“冲突”状态,从未实现。
现在那里有其他问题,再次提出了解决该问题的建议。但作者,遗憾的是,正在等待 PR。
在我 [一个问题] (https://github.com/himiklab/yii2-recaptcha-widget/issues/57) 上,他给我写道:“我欠某人什么?”当然,然后它被删除了。但我收到了带有这条消息的电子邮件。
当然不是。但我们也不欠你。但写:“抱歉我太忙了,在 <...> 查找错误” - 这是最佳实践。使用它。
感谢 himiklab & den67rus 为本发行版提供基础