php - how to get data from other tables in grid view in yii -
i have module named attendance value in comes other tables conditions. how can id of other tables. code below:
models are:
if($type == 2) { $model = new supplier(); } elseif($type==3) { $model = new truckingcompany(); } elseif($type==4) { $model = new serviceprovider(); } elseif($type==5) { $model = new landowner(); } elseif($type==6) { $model = new refiner(); } elseif($type==8) { $model = new worker(); } elseif($type==9) { $model = new trainer(); }
now want update record
array( 'header'=>'action', 'class' => 'cbuttoncolumn', 'template'=>'{update}', 'updatebuttonurl'=>'yii::app()->createurl("attendance/update", array("id"=>$data->id))', );
now want id of these diffent table update record , these different in tables. can below line:
'updatebuttonurl'=> 'yii::app()->createurl("attendance/update", array("id"=>$data->supplier_master_id))';
but not proper way define these tables in case... idea... new in yii.
why not create url along models like
if($type == 2) { $model = new supplier(); $updateurl = 'yii::app()->createurl("attendance/update", array("id"=>$data->id))'; } elseif($type==3) { $model = new truckingcompany(); $updateurl = 'yii::app()->createurl("attendance/update", array("id"=>$data->supplier_master_id))'; }
pass view while rendering
$this->render('view',array('updateurl'=>$updateurl));
and use in view file like
array( 'header'=>'action', 'class' => 'cbuttoncolumn', 'template'=>'{update}', 'updatebuttonurl'=>$updateurl, );
Comments
Post a Comment