내 호스트에서 이러한 유형의 오류가 발생하지만 내 localhost에는 오류가 없습니다. 관계 이름을 사용하여 값을 표시 할 때 호스트에서 오류가 사라집니다 (예 : model.attribute
). 무엇이 문제 일 수 있습니까?Yii 비 객체의 속성을 얻으려고 시도합니다.
<h1>Управление операциями</h1>
<?php $this->widget('bootstrap.widgets.BootGridView',array(
'id'=>'operations-grid',
'type'=>'striped bordered',
'dataProvider'=>$model->search(),
//'filter'=>$model,
'columns'=>array(
array(
'name'=>'operationType',
'value'=>'$data->operationType->name',
'header'=>'Операция'
),
array(
'name'=>'creation_date',
'type'=>'datetime',
'header'=>'Дата создания'
),
'ammount_usd:raw:Сумма',
'comment:text:Комментарий',
array(
'name'=>'currency',
'value'=>'$data->currency->short',
'header'=>'Валюта',
),
array(
'name'=>'client',
'value'=>'$data->client->fio',
'header'=>'Клиент',
),
array(
'name'=>'organization',
'value'=>'$data->organization->name',
'header'=>'Организация',
),
array(
'class'=>'bootstrap.widgets.BootButtonColumn',
'header'=>'Action'
),
),
)); ?>
감사 :
여기public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('ammount, currency_id, operation_type', 'required'),
array('currency_id, operation_type, client_id, organization_id', 'numerical', 'integerOnly'=>true),
array('creation_date, modification_date, ammount, ammount_usd', 'length', 'max'=>10),
//array('ammount, currency_id, operation_type, client_id, organization_id,comment', 'safe'),
array('ammount, ammount_usd, currency_id, operation_type, client_id, organization_id, currency,comment,
operationType ,client, organization', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'client' => array(self::BELONGS_TO, 'Client', 'client_id'),
'currency' => array(self::BELONGS_TO, 'Currencies', 'currency_id'),
'organization' => array(self::BELONGS_TO, 'Organizations', 'organization_id'),
'operationType' => array(self::BELONGS_TO, 'OperationType', 'operation_type'),
'operationsMeta' => array(self::HAS_MANY, 'OperationsMeta', 'operation_id'),
);
}
가 보기 파일입니다
은 여기 내 모델입니다.
오류 발생 줄은 무엇입니까? – Stu
추적하는 동안 $ data-> client-> fio 라인에서 실패했음을 알게되었습니다. fio는 클라이언트 모델에 공용 getter가있는 가상 필드입니다. 이 코드가 로컬에서는 작동하지만 호스트 서버 –
에서는 $ data-> client가 비어 있거나 특정 모델에 대한 레코드가 없다는 것을 알지 못한다는 이상이 있습니까? – Stu