I need to know how to call relationship in listData() ,
For Example in normal way we can call it like :
$model->section->section_name ;
in my code i just print value as number but I need to print string value from courses table .
public function coursesList($section_id) {
$data=Msection::model()->findAll('section_id=:section_id',
array(':section_id'=>(int)$section_id));
return CHtml::listData($data,'course_id','course_id');
//// can i call it like : ///listData($data,'course_id->course->course_name','course_id');
}
Can I call it like:
listData($data,'course_id->course->course_name','course_id');
How To fix that ?
Thanks in advance
If you are using php 5.3 or more you could call an anonymous function in your ListData where the paramater is the model that the list is working on at this time:
Source: Yii documentation