Dropdown Value To Cgrid Condition

I was asked to show a list of events in a CgridView , and to add a dropdown hat will filter them by week/date.

Now , my first thought was to use the "advanced search" , but the value I need to filter by is in another related model.

So question number 1: can I add a relation filter in the advanced search form page?

If ,not , i created the following dropdown:

$week=CHtml::listData(Week::model()->findAll(array('order'=>'start_date DESC')), 'id','number','start_date');

	echo CHtml::dropDownList('weeks', $week, $week, array('empty' => ''));

which is working , but not I don’t know how to pass the selected value to the gridView’s search condition which is in the same page (preferably without the need of a button click)


Any ideas about both options?



this article is along the lines of what you are looking for I think

The link is not working

try this: http://www.yiiframework.com/wiki/648/update-gridview-with-dropdown-selection/

If you are about to use the advanced search, maybe you can use join table.

Refer this http://www.yiiframework.com/forum/index.php/topic/54569-cgridview-filter-and-sql-errore/page__view__findpost__p__250629

I ended up using the related model in the search form.


Thanks you all.