How to display a related HAS_MANY grid

I found this on McGuigan 's blog at

That works find but how to do if I want cars of dealers which category= ‘some category’ ?




Is better to use a CActiveDataProvider:

$dataProvider = new CActiveDataProvider('cars', array(


        'condition'=>"category= 'some category' and dealer='{$model->id}'"



I just try that

and I have this error

I have this in my dealer model :

It seems to be too complicate…

Nobody to help me? I need that…


Hi Fouss,

I think you want ‘car’ instead of ‘cars’ in the CActiveDataProvider part, as that is your model name


Yes it works with ‘car’ but I want to use the relation cars but I want to use the relation ‘cars’. How to do that?

I think you should use