How to display a related HAS_MANY grid

I found this on McGuigan 's blog at http://learnyii.blogspot.com/2010/12/yii-how-to-display-related-hasmany-grid.html

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

dealer(id,name,category)

car(id,type,colour,dealer_id)

thanks!

Is better to use a CActiveDataProvider:


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

   'criteria'=>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…

thx!

Hi Fouss,

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

Neil

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




'with'=>'relation'