dou44364983 2016-05-30 11:25
浏览 47

另一个yii - 试图获得非对象的属性

sory another yii question, try this bust seems doesnt works. I have this error, still learning yii

Trying to get property of non-object D:\xampp\htdocs\mou\protected\views\mou\view.php(26)

Did i miss something? thanks before.

D:\xampp\htdocs\mou\protected\views\mou\view.php(26)

14             'value'=>Yii::app()->dateFormatter->format('dd/MM/yyyy',$model->tgl_perjanjian),
15         ),
16         array(
17             'name'=>'tgl_awal',
18             'value'=>Yii::app()->dateFormatter->format('dd/MM/yyyy',$model->tgl_awal),
19         ),
20         array(
21             'name'=>'tgl_akhir',
22             'value'=>Yii::app()->dateFormatter->format('dd/MM/yyyy',$model->tgl_akhir),
23         ),
24         array(
25             'name'=>'Mitra KY',
26             'value'=>$model->mitra_mous->mitra->nama,
27         ),
28         'lingkup_kerjasama',
29         'penandatangan',
30         'jabatan_penandatangan',
31         array(
32             'name'=>'file',
33             'type'=>'raw',
34             'value'=>CHtml::link($model->file,Yii::app()->baseUrl . '/files/mou/' .$model->file),
35         ),
36     ),
37 )); ?>

this is my models Mitra.php

    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(
            'jenis0' => array(self::BELONGS_TO, 'JenisMitra', 'jenis'),
            'kab0' => array(self::BELONGS_TO, 'Wilayah', 'kab'),
            'prov0' => array(self::BELONGS_TO, 'Wilayah', 'prov'),
            'mitra_mous' => array(self::HAS_MANY, 'MitraMou', 'mitra_id'),
        );
    }

and this is models Mou.php

    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(
            'mitra_mous' => array(self::HAS_MANY, 'MitraMou', 'mou_id'),
            'mitras' => array(self::HAS_MANY, 'Mitra', 'mitra_id','through'=>'mitra_mous'),
        );
    }

</div>
  • 写回答

2条回答 默认 最新

  • dongyuan7981 2016-05-30 11:45
    关注

    Change your line 26 to the code below.

    use this code below

    'value'=>$model->mitras->nama,

    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探