PHP code example of m1roff / yii2-recaptcha-widget
1. Go to this page and download the library: Download m1roff/yii2-recaptcha-widget library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
public $reCaptcha;
public function rules()
{
return [
// ...
[['reCaptcha'], \m1roff\yii2\recaptcha\ReCaptchaValidator2::class,
'secret' => 'your secret key', // unnecessary if reСaptcha is already configured
'uncheckedMessage' => 'Please confirm that you are not a bot.'],
];
}
public $reCaptcha;
public function rules()
{
return [
// ...
[['reCaptcha'], \m1roff\yii2\recaptcha\ReCaptchaValidator3::class,
'secret' => 'your secret key', // unnecessary if reСaptcha is already configured
'threshold' => 0.5,
'action' => 'homepage',
],
];
}
<?= $form->field($model, 'reCaptcha')->widget(
\m1roff\yii2\recaptcha\ReCaptcha2::class,
[
'siteKey' => 'your siteKey', // unnecessary is reCaptcha component was set up
]
)
<?= $form->field($model, 'reCaptcha')->widget(
\m1roff\yii2\recaptcha\ReCaptcha3::class,
[
'siteKey' => 'your siteKey', // unnecessary is reCaptcha component was set up
'action' => 'homepage',
]
)
<?= \m1roff\yii2\recaptcha\ReCaptcha2::widget([
'name' => 'reCaptcha',
'siteKey' => 'your siteKey', // unnecessary is reCaptcha component was set up
'widgetOptions' => ['class' => 'col-sm-offset-3'],
])
<?= \m1roff\yii2\recaptcha\ReCaptcha3::widget([
'name' => 'reCaptcha',
'siteKey' => 'your siteKey', // unnecessary is reCaptcha component was set up
'action' => 'homepage',
'widgetOptions' => ['class' => 'col-sm-offset-3'],
])
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.