[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']:[];
                }
            ],
原文地址:https://www.cnblogs.com/hsd1727728211/p/6137699.html