Hi!
I follow this guide to create a cgridview allowing to searching and sorting related model:
http://www.yiiframework.com/wiki/281/searching-and-sorting-by-related-model-in-cgridview/
Here are my relations:
license BELONGS_TO install
install BELONGS_TO node
I can by this way create a CGridview with any field of my license and install models. However, I can have fields of the node model, But I have the following error when searching on it:
I don’t understand, my table node is linked in my search fuction.
Here is my CGridview on model license:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'t-license-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'name'=>'siteId_search',
'value'=>'$data->install->node->f_site_id',
'header'=>'Site',
),
array(
'name'=>'installId_search',
'value'=>'$data->install->f_install_id',
'header'=>'installId',
),
[...]
),
));
And my my license model:
public $siteId_search;
public $installId_search;
[...]
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->with=array('install.node', 'install.product');
$criteria->compare( 'install.node.f_site_id', $this->siteId_search, true );
$criteria->compare( 'install.f_install_id', $this->installId_search, true );
[...]
return new CActiveDataProvider('t_licence', array(
'criteria'=>$criteria,
));
}
Any Idea? You can see that my search function also call table install.product, I have the same problem on it.