我使用的是Yii 1.15 我的视图显示上面的错误。我不知道为什么。但这里有详细信息:
我的控制器:
public function actionView($id)
{
// cek login admin
IsAuth::Admin();
// panggil function loadModel() dan tampung ke $dataOrder
$dataOrder = $this->loadModel($id);
//find data ConfirmPayment berdasarkan order_code
$dataConfirmPayment = ConfirmPayment::model()->findByAttributes(array('order_code' => $dataOrder->order_code));
// find data alamat pengiriman berdasarkan address_id
$dataConfirmPayment = Address::model()->findByPk($dataOrder->address_id);
// panggil model Orderdetail & function search
$model = new Orderdetail('search');
// clear any default values
$model->unsetAttributes();
// set select data order_detail berdasarkan order_code
$model->order_code = $dataOrder->order_code;
// render ke orders view
$this->render('view',array(
'model' => $dataOrder,
'ordet' => $model,
'dataPayment' => $dataConfirmPayment,
'shippingAddress' => $dataShippingAddress,
));
}
我的观点:
$this->widget('zii.widgets.CDetailView', array(
/*data alamat pengiriman*/
'data'=>$shippingAddress,
'attributes'=>array(
array(
'type'=>'HTML',
'name'=>'name',
'value'=>$shippingAddress->name,
),
),
Hopefuly我更好地描述了我的问题。
答案 0 :(得分:1)
我认为问题出在这里
//find data ConfirmPayment berdasarkan order_code
$dataConfirmPayment = ConfirmPayment::model()->findByAttributes(array('order_code' => $dataOrder->order_code));
// find data alamat pengiriman berdasarkan address_id
$dataConfirmPayment = Address::model()->findByPk($dataOrder->address_id);
您要将值分配给 $ dataConfirmPayment 两次。
第二个变量应为 $ dataShippingAddress
即
//find data ConfirmPayment berdasarkan order_code
$dataConfirmPayment = ConfirmPayment::model()->findByAttributes(array('order_code' => $dataOrder->order_code));
// find data alamat pengiriman berdasarkan address_id
$dataShippingAddress= Address::model()->findByPk($dataOrder->address_id);