$status=1 or 0 然后显示 Enable or disable respected how can translate in yii2 MVC

$status=1 or 0 then display Enable or disable respected how can translate in yii2 MVC

我的数据库列 "status" 存储“0 或 1”值,但我想显示 "Enable" 或 "disable"

试试这个...这可能对您有所帮助。

根据需要修改代码。

  [
            'attribute' => 'status',
            'value' => function ($model, $key, $index, $widget) {
        if ($model->status == 0) {
            $status = 'disable';
        } elseif ($model->status == 1) {
            $status = 'Enable';
        } else {
            $status = 'Completed';
        }
        return $status;
    }
    ]