社区最帅的八戒 2015-07-12 16:48:39 3554次浏览 0条回复 0 0 0

我参考了多个人的知道了调用咋写但是输出完全没眉头 新建了个 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));//变量传到前台模版
    }

如果有什么不对的地方请指教

    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册