DetailView内匿名函数不可用

DetailView

yii\widgets\DetailView 小部件显示的是单一 yii\widgets\DetailView::$model 数据的详情。

它非常适合用常规格式显示一个模型(例如在一个表格的一行中显示模型的每个属性)。 这里说的模型可以是 \yii\base\Model 或者其子类的一个实例,例如子类 active record,也可以是一个关联数组。

DetailView使用 yii\widgets\DetailView::$attributes 属性来决定显示模型哪些属性以及如何格式化。 可用的格式化选项,见 formatter section 章节。

一个典型的DetailView的使用方法如下:

echo DetailView::widget([
    'model' => $model,
    'attributes' => [
        'title',               // title attribute (in plain text) 'description:html', // description attribute formatted as HTML [ // the owner name of the model 'label' => 'Owner', 'value' => $model->owner->name, ], 'created_at:datetime', // creation date formatted as datetime ], ]); 

转载于:https://www.cnblogs.com/jerrypro/p/6413252.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值