PHP code example of efremovp / yii2-ya-smart-captcha

1. Go to this page and download the library: Download efremovp/yii2-ya-smart-captcha 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/ */

    

efremovp / yii2-ya-smart-captcha example snippets


return [
    //....
    'ya_captcha' => [
        'error_message' => 'Подтвердите, что вы не бот.',
        'client_key' => '******',
        'server_key' => '******'
    ],
];

php composer.phar 

<?= \efremovP\YaCaptcha\YaCaptchaWidget::widget(['form' => $form, 'model' => $model]) 


namespace frontend\models;

use Yii;
use yii\base\Model;

/**
 * Login form
 */
class LoginForm extends Model
{
    public $yaCaptcha; // add captcha field


    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            // add captcha rules
            ['yaCaptcha', '

<?= \efremovP\YaCaptcha\YaCaptchaWidget::widget(['form' => $form, 'model' => $model, 'successCallback' => 'successCaptchaCallback']) 

<?= \efremovP\YaCaptcha\YaCaptchaWidget::widget(['form' => $form, 'model' => $model, 'lang' => 'en'])