Yii2.0如果输出 <img src="验证码" /> [ 求助交流 ]
我参考了多个人的知道了调用咋写但是输出完全没眉头
新建了个 LoginForm.php
namespace backend\models;
use yii\base\Model;
use yii\captcha\Captcha;
class LoginForm extends Model
{
    public $verifyCode;
    /**
     * Declares attribute labels.
     */
    public function attributeLabels()
    {
        return [
            'verifyCode' => 'Verification Code',
        ];
    }
}
然后我回到了我的LoginController.php
use backend\models\LoginForm;
//验证码方法
    public function actions()
    {
        return  [
//                 'captcha' =>
//                    [
//                        'class' => 'yii\captcha\CaptchaAction',
//                        'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
//                    ],  //默认的写法
            'captcha' => [
                'class' => 'yii\captcha\CaptchaAction',
                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
                'backColor'=>0x000000,//背景颜色
                'maxLength' => 6, //最大显示个数
                'minLength' => 5,//最少显示个数
                'padding' => 5,//间距
                'height'=>40,//高度
                'width' => 130,  //宽度
                'foreColor'=>0xffffff,     //字体颜色
                'offset'=>4,        //设置字符偏移量 有效果
                //'controller'=>'login',        //拥有这个动作的controller
            ],
        ];
    }
//定义公用视图文件方法
//    public $layout = 'common';
    public function actionIndex(){
        $loginForm = new LoginForm();
        return $this->render('index',array('loginForm'=>$loginForm));//变量传到前台模版
    }
如果有什么不对的地方请指教
共 0 条回复
没有找到数据。
社区最帅的八戒
            注册时间:2015-07-01
最后登录:2015-08-12
在线时长:2小时13分
    最后登录:2015-08-12
在线时长:2小时13分
- 粉丝0
- 金钱44
- 威望0
- 积分64
