[moka同学笔记]四、Yii2.0课程笔记(魏曦老师教程)[匿名函数的使用操作]

在评论页面中index.php中

            [
                'attribute'=>'status',
                'value'=>'status0.name',
                'filter'=>Commentstatus::find()->select(['name','id'])->orderBy('position')->indexBy('id')->column(),
                'contentOptions'=>function($model){ //此处使用匿名函数来判断状态,设定状态的样式
                    return ($model->status==1)?['class'=>'bg-danger']:[];
                }
            ],

 

posted @ 2016-12-06 15:10  mokal同学  阅读(198)  评论(0编辑  收藏  举报