Reference : http://hafiznor.wordpress.com/ 2014/05/15/yii-cgridview-show- relations-has_many-in- gridview/
Make sure you have the relations object:
public function relations() { return array( 'example' => array(self::HAS_MANY, 'exTask', 'ex_id'), ); }
Add function in your model file:
public static function extractObjData($objData) { $tmp = '<div class="edata">'; foreach ($objData as $obj) { $tmp = $tmp . $obj->name . '<br/>'; }
$tmp = $tmp.'</div>'; return $tmp; }
In your GridView columns:
array( 'header' => 'PEOPLE', 'value' => 'HumanModel::extractObjData($data->example)', 'type' => 'raw', ),
No comments:
Post a Comment