qingbing / pf-widgets-captcha
渲染部件——图片验证码,验证码模型验证
1.0.1
2019-05-21 09:09 UTC
Requires
- qingbing/php-helper: >=1.0, <2.0
- qingbing/php-model: >=1.0, <2.0
Requires (Dev)
- qingbing/php-file-cache: >=1.0, <2.0
- qingbing/php-html: >=1.0, <2.0
- qingbing/php-render: >=1.0, <2.0
- qingbing/php-session: >=1.0, <2.0
- qingbing/php-web: >=1.0, <2.0
This package is auto-updated.
Last update: 2025-04-21 22:40:18 UTC
README
描述
渲染部件——图片验证码,验证码模型验证
注意事项
- 该组件基于"qingbing/php-render"上开发运行
- "\Captcha" 必须配置在继承了"\Render\Controller"的控制器上
- 默认 ?refresh=1表示获取一个新的验证码的地址的接收回调
- 支持验证码的模型验证,验证类型为验证类名"\CaptchaSupports\CaptchaValidator",简化为:"\Captcha::VALIDATOR"
- 如果使用视图小部件"\Widgets\Captcha",务必注意一下几点
- 在页面头引入jquery组件
使用方法
1. 验证码控制器声明
/** * 定义外部action列表 * @return array */ public function actions() { return [ 'captcha' => [ 'class' => '\Captcha', 'attribute1' => 'value1', 'attribute...' => 'value...', ], ]; }
2. 验证组件视图使用方法
$this->widget('\Widgets\Captcha', [ 'action' => '/site/captcha', 'alt' => '验证码', 'attributes' => [ 'id' => 'xxxx', 'otherAttributes' => 'otherAttributes', ], ]);
3. 模型验证配置
class TestLoginModel extends FormModel { /* 验证码 */ public $verifyCode; public function rules() { return [ ['verifyCode', \Captcha::VALIDATOR, 'captchaAction' => 'site/captcha', 'allowEmpty' => false], ]; } }
====== 异常代码集合 ======
异常代码格式:1023 - XXX - XX (组件编号 - 文件编号 - 代码内异常)
- 102300101 : \CaptchaSupports\CaptchaValidator.action"{id}"无效,无法找到指定的action