PHP code example of qingbing / pf-widgets-captcha

1. Go to this page and download the library: Download qingbing/pf-widgets-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/ */

    

qingbing / pf-widgets-captcha example snippets


    /**
     * 定义外部action列表
     * @return array
     */
    public function actions()
    {
        return [
            'captcha' => [
                'class' => '\Captcha',
                'attribute1' => 'value1',
                'attribute...' => 'value...',
            ],
        ];
    }

$this->widget('\Widgets\Captcha', [
    'action' => '/site/captcha',
    'alt' => '验证码',
    'attributes' => [
        'id' => 'xxxx',
        'otherAttributes' => 'otherAttributes',
    ],
]);


class TestLoginModel extends FormModel
{
    /* 验证码 */
    public $verifyCode;

    public function rules()
    {
        return [
            ['verifyCode', \Captcha::VALIDATOR, 'captchaAction' => 'site/captcha', 'allowEmpty' => false],
        ];
    }
}