为什么我的异常消息不能输出啊
if(!$model->create()){ //如果错误,提示错误信息 Yii::$app->session->setFlash('warming',$model->_lastError); }else{ return $this->redirect(['post/view','id'=>$model->id]); }
出错的时候,这个异常信息在视图上不会显示
视图文件create.php
<?php /** * Created by PhpStorm. * User: wjl * Date: 2018/8/16 * Time: 16:31 */ use yii\helpers\Html; use yii\bootstrap\ActiveForm; //添加标题 $this->title = '创建'; $this->params['breadcrumbs'][] =['label'=>'文章','url'=>['post/index']];//设置一个标签,并给定指向url $this->params['breadcrumbs'][] = $this->title; ?> <div class="row"> <div class="col-lg-9"> <div class="panel-title box-title"> <span>创建文章</span> </div> <div class="panel-body"> <?php $form=ActiveForm::begin() ?> <!--yii的表单组件 yii可以直接使用$调用控制传过来的变量--> <?= $form->field($model, 'title')->textInput(['maxlength'=>true]) ?> <?= $form->field($model, 'cat_id')->dropDownList($cat) ?> <?= $form->field($model, 'label_img')->widget('common\widgets\file_upload\FileUpload',[ 'config'=>[ //图片上传的一些配置,不写调用默认配置 ] ]) ?> <?= $form->field($model, 'content')->widget('common\widgets\ueditor\Ueditor',[ 'options'=>[ 'initialFrameWidth' => 850, 'initialFrameHeight' => 200, ] ]) ?> <?= $form->field($model, 'tags')->widget('common\widgets\tags\TagWidget') ?> <div class="form-group"> <?= Html::submitButton('发布', ['class' => 'btn btn-primary']) ?> </div> <?php $form=ActiveForm::end() ?> </div> </div> <div class="col-lg-3"> <div class="panel-title box-title"> <span>注意事项</span> </div> <div class="panel-body"> 1.asasa<br> 2.asasa </div> </div> </div>