Cgridview Search On Relation Name

Hi guys.

First: i have googled this, and found endless ammount of forum-threads and tutorials, but i still cant seem to make it work.

I have a model called Wine. That has its country and region represented by a id.

I want the gridview to generate the region and country names, and allso the filterboxes to respond if you write the country or region name.

In my model:

public function relations()


		return array(

				'GetRegion' => array(self::BELONGS_TO, 'Region', 'region', 'alias' => 'r'),

				'GetCountry' => array(self::BELONGS_TO, 'Country', 'country', 'alias' => 'c'),



My Controller:

	public function actionIndex()


		$model=new Wine('search');

		$model->unsetAttributes();  // clear any default values



		$this->render('index', array(





And my view:


$this->widget('zii.widgets.grid.CGridView', array(










)); ?>

Ive tried with and with $data->GetRegion->name, but errormessage on both.

Anyone have any inputs? Ive been stuck for hours :confused:

Thanks in advance!









Works, but the filterboxes disapear.

Tried Model:



Does not help.

Ah, yes, it seems "endless". Partly because of the lack of an official tutorial on this matter, many people have some difficulty in using CGridView and CActiveDataProvider.

The most useful document on this topic, IMO, is a wiki named "Searching and sorting by related model in CGridView".

It has been proved to be useful by many people. Please read it carefully, the answer is there.

Thank you, kindly.