模型中操作

public function getZhifuListTextAttr($value, $data)
{
    $value = $value ? $value : (isset($data['zhifu_state']) ? $data['zhifu_state'] : '');
    $list = $this->getZhifuList();
    return isset($list[$value]) ? $list[$value] : '';
}
 
public function getZhifuList(){
    return ['0' => __('Zhifu_state 0'), '1' => __('Zhifu_state 1')];
}

视图中使用

{$row.zhifu_list_text}

发表评论

邮箱地址不会被公开。 必填项已用*标注