Yii2 view 层显示值
1). Yii2 view 层显示值
[ 'attribute'=>'字段名', 'format' => 'raw', 'value'=> call_user_func(function ($model){ $img_url = "图片路径"; return Html::a( Html::img($img_url, ['style'=>'height:100px;height:80px']), $img_url, ['target'=>'_blank']); },$model) ];
2).数据转换, 时间戳格式化; 官方参考地址
class Customer extends ActiveRecord { // ... public function getBirthdayText() { return date('Y/m/d', $this->birthday); } public function setBirthdayText($value) { $this->birthday = strtotime($value); } }
// 现在可以使用 $customer->birthdayText; 而不是 $customer->birthday
3) Yii2 view 层显示值02
[ 'class' => 'yii\grid\ActionColumn', 'header' => '操作', 'template' => '{view} {update} {delete}', ],
其他: https://packagist.org/packages/yiithings/yii2-softdelete
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步