Search on related table

I have the following relation in model file:

'	public function relations()



	'railways' => array(self::BELONGS_TO, 'Railways', 'railway'),

	..			}

The table railways has a column ‘zone’.

I now modify the model search functiion thus.

	public function search()




	..			}

When I run the application I get the ‘Column not found error’ on

Where am I making the mistake? Thanks.


try this


this should work.

$criteria->with = array('railways');

@Thanks mbi. Missed it!! Now works.


 $criteria->with = array('railways','equipments'...);


for more than one related table.

So you have a main table and Railways table with "zone" field. If you wanted to add "zone" field in the Advanced Search form (admin.php) of the main table, how would you accomplish?