Search filter missing for added field in CGriedView


following the steps described here

I added in CGridView a foreign key field showing data from a relationed table. All is working fine, a part that this new field has not the search filter box in the header of the table. How can I add it?


Without your code there is not much I can do. However, the most common reason for the filter not being shown is that the name attribute is null for the column in question.

In the model i put the tables into relation with

public function relations()


		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

			'azienda'=>Array(self::BELONGS_TO, 'Azienda', 'azienda_id'),



In the admin view file i added the field of the related table (zienda.denominazione):

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

















What do you mean with "name attribute is null for the column in question"? Where this attribute has to be configured?


This is the guide you probably want. Start over there, and follow those steps exactly. In addition, make sure that the field in the related model you’re trying to search on in is safe. If you are still stuck, come back and let us know!

This was exactly what I nedeed!! Now it works!!!