Error 500 Trying to get property of non Object

I have problem ,

always get Error 500 "Trying to get property of non Object" while i try to show Notrans_FPB in my Cgridview, can anyone help me ? whats wrong with my code ,

Thanks …

This is my Controller "DafTimbangBahan"




    	public function actionAdmin()

	{

		$model=new DafTimbangBahan('search');

		$dafFpbs=new DafFpb;

		

		$model->unsetAttributes();  // clear any default values

		if(isset($_GET['DafTimbangBahan']))

			$model->attributes=$_GET['DafTimbangBahan'];


		$this->render('admin',array(

			'model'=>$model,

		));

	}



My Model DaftimbangBahan




	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(

			'dafBpbs' => array(self::HAS_MANY, 'DafBpb', 'Notrans'),

			'dafFpbs' => array(self::HAS_MANY, 'DafFpb', 'Notrans'),

			'koSup' => array(self::BELONGS_TO, 'Supplier', 'KoSup'),

			'koCab' => array(self::BELONGS_TO, 'Cabang2', 'KoCab'),

			'bahans' => array(self::MANY_MANY, 'Bahan', 'det_timbang_bahan(Notrans, KoHan)'),

			'notransTimbangs' => array(self::HAS_MANY, 'NotransTimbang', 'Notrans'),

		);

	}



and This is my View File




        <?php $this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'daf-timbang-bahan-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(	

		array(

		'name'=>'dafFpbs.Notrans_FPB',

        'header'=>'No. FPB',

        'value'=>'$data->dafFpbs->Notrans_FPB',

		),

		'NoTrans',

		array(

			'class'=>'CButtonColumn',

		),

	),



I don’t think this is valid:




'name'=>'dafFpbs.Notrans_FPB',



See if the error goes away when you remove that line.

If you need to be able to filter on that attribute, you’ll need to add an extra attribute into the DafTimbangBahan class (something like $search_dafFpbs_Notrans_FPB), include that in the ‘search’ rules entry, make sure you join the table in your search() method, then add an extra search condition for the field.

EDIT

Also, this line:




'value'=>'$data->dafFpbs->Notrans_FPB',



will cause the error you saw if there is no associated dafFpbs record. You should guard that with this sort of pattern:




'value'=>'isset($data->dafFpbs) ? $data->dafFpbs->Notrans_FPB : ""',