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.
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 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!