类别:YII / 日期:2020-01-12 / 浏览:195 / 评论:0
yii的数据库配置信息在哪里_yii框架教程
yii公共的数据库配置文件在/common/config/main-local.php。若前后台不同:前台在/frontend/config/main-local.php,后台在/backend/config/main-local.php。
yii 验证码不显示图片怎么办?
yii2中验证码的使用-图片不显示
推荐学习:yii框架
1.控制器中
public function actions() { return [ 'captcha' => [ 'class' => 'yii\captcha\CaptchaAction', 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, ], ]; }
2.模型中
要有一个验证码的字段$verifyCode
3.视图中
use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\captcha\Captcha;
自动生成表单
页面中验证码代码
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [ 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', ]) ?>
控制器中的权限可能导致验证码图片不显示,
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout', 'signup','login'],
'rules' => [
[
yii2怎么定义错误页面_yii框架教程
yii2定义错误页面的方法:先在views/site/error.php文件中设置错误页面样式。然后在config/main.php文件中使用“'errorAction'=>'site/error',”语句调用即可。
'actions' => ['signup'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
控制器中红线部分缺少则导致验证码不显示。
以上就是yii 验证码不显示图片怎么办的详细内容,更多请关注ki4网其它相关文章!
yii2框架怎么实现注册_yii框架教程
yii2框架实现注册的方法:在yii框架中提交注册信息后rules()函数会进行初步验证,所有格式正确后数据传输到actionSignup()函数中,然后在signup()函数中加载注册信息。