php - Accessing value of indirectly related models -
i displaying cgridview below cdetailview on view.php page company model. have problem in displaying values in cgridview using company details. company model has array of companyaddresses used carraydataprovider cgridview.
$config = array(); $dataprovider = new carraydataprovider($rawdata=$model->companyaddresses,$config); $this->widget('zii.widgets.grid.cgridview', array( 'dataprovider'=>$dataprovider , 'columns'=>array( //'id', array('header'=>'sn.', //'value'=>'++$row', // may nt work pagination below work 'value'=>'$this->grid->dataprovider->pagination->currentpage * $this->grid->dataprovider->pagination->pagesize + ($row+1)', ), 'address', array( 'name'=>'tehsil', //'value'=> utility::gettehsilname(tehsil::model()->findbypk('tehsil_id')), 'value'=> utility::gettehsilname($this->loadmodel('tehsil_id')), //'value'=> tehsil::model()->findbyattributes( array('id' => 'tehsil_id' ) )->name, ), array( 'name'=>'address_tag_id', 'value'=>addresstag::model()->findbypk('address_tag_id'), ), ) ));
i not able fetch tehsil_name tehsil table has id inside companyaddress table.
your using value attribute wrong, check this:
'value'=>function($data){ return utility::gettehsilname($data->tehsil_id); },
Comments
Post a Comment