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:
array(
'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.
I’m not sure what “email_id” and $id would be refering to, the model CourseEcts only has one property -> ects_points which is therefore the primary key.
Course.ects_points is a foreign key to CourseEcts.ects_points and CoursePeriod.course is a foreign key to Course.course_id.