alex-w
(Pr0j3ct A1ex)
1
Just can’t seem to work it out, Data from the relation doesn’t return.
$model = new Model('search');
$search = $model->together()->with('related')->search();
$this->widget('CGridView', array(
'dataProvider' => $search,
'filter' => $model
....
....
array(
'value' => '$data->relatedAttr',
),
It works with lazy loading but I need eager.
Asgaroth
(Asgaroth Belem)
2
Shouldn’t it be?
array(
'value' => '$data->related->relatedAttr',
),
alex-w
(Pr0j3ct A1ex)
3
But that uses lazy loading (unless I’m mistaken).
forgot to mention relation,
'related' => array(
self::BELONGS_TO,
'RelatedModel',
'key'
)
Asgaroth
(Asgaroth Belem)
4
I dont understand the use of with here:
$search = $model->together()->with('related')->search();
I think if should be in your search method:
public function search(){
$criteria = new CDbC...
$criteira->compare...
$criteria->with = array('related');//Here
return CAcviteDataProvider...
}
alex-w
(Pr0j3ct A1ex)
5
Yep that was it, Knew I was overlooking something.
Looking at it now I can see the search method doesn’t use the model instance for creating the provider.
thanks.
Asgaroth
(Asgaroth Belem)
6
Nope, the Dataprodiver just requires the name of the model 
Good to know its now working, please mark this topic as resolved, thanks! 