How to convert model data objects array to dataProvider
问题 Suppose I have model User which have many to many relation to itself named as friends . so $user->friends (or $model->friends in view) gives me an array of User objects. I wanted to display the friends as gridview. But CGridView data as dataProvider object. Googling for it found the way to convert array of model objects to dataProvider object as given below. $this->widget('zii.widgets.grid.CGridView', array( 'id' => 'gridUser', 'dataProvider' => new CArrayDataProvider($model->friends, array()