我认为我有以下代码:
<?php $this->widget('zii.widgets.CDetailView', array(
'data' => $model,
'attributes' => array(
'id',
'name',
array(
'label' => 'Company',
'type' => 'raw',
'value' => 'CJSON::decode($data->json)["Block"]["p_1"]',
),
),
)); ?>
我的数据库中有一个名为 json 的字段。该字段包含 json 格式的数据。我使用以下代码来解码 json 数据:
array( 'label' => 'Company',
'type'=>'raw',
'value' =>'CJSON::decode($data->json)["Block"]["p_1"]',
),
当我在CGridView中使用这个 json 解码代码时,它可以工作并返回所需的值。但是,当我在 CDetailView 中使用此代码时,它不起作用。小部件返回此代码CJSON::decode($data->json)["Block"]["p_1"]
而不是解码数据。如何在 CDetailView 中解码 json 数据?