I have a gridview of courses using 2 related models. I’ve managed to get filtering working by putting properties in the main model, putting them in the rules as safe on search and then referencing them in the search method criteria. For one of the columns which is from the related model, I have a dropdown as follows:
'header' => 'ECTS',
'name' => 'search_ects_points', // property added to CoursePeriod model
'value' => '$data->course->ects_points', // related model
'filter' => CHtml::listData(CourseEcts::model()->findAll(), 'ects_points', 'ects_points'), // for the dropdown pulling from CourseEcts model
This pulls all possible ECTS points from the model CourseEcts which is related to Course (Course.ects_points belongs to CourseEcts.ects_points).
The dropdown displays and filters perfectly, however my gridview has a condition to only show courses by the current year. This year there will only be 2 possible ects points (5 and 10) but the dropdown shows 5, 6, 10 and 15 which are all possible ects points in the database.
Is there a way to make the dropdown only show ects points based on this condition? Basically filtering the filter.
I haven’t supplied any code to keep the post short, but if you need some code to see how everything is set, just let me know.