title: How to convert model data objects array to dataProvider
body: <p>Suppose I have model <code>User</code> which have many to many relation to itself named as <code>friends</code>.
  so <code>$user-&gt;friends</code> (or <code>$model-&gt;friends</code> in view) gives me an array of <code>User</code> objects. I wanted to display the friends as gridview. But <code>CGridView</code> data as <code>dataProvider</code> object. Googling for it found the way to convert array of model objects to <code>dataProvider</code> object as given below.</p>
  
  <pre><code>$this-&gt;widget('zii.widgets.grid.CGridView', array(
      'id' =&gt; 'gridUser',
      'dataProvider' =&gt; new CArrayDataProvider($model-&gt;friends, array()),
  ));
  </code></pre>
  
  <p>Now using this I get an error </p>
  
  <blockquote>
    <p>Property "User.id" is not defined.</p>
  </blockquote>
  
  <p>UPDATE</p>
  
  <pre><code>public function relations()
  {
      return array(
           'friends' =&gt; array(self::MANY_MANY, 'User', 'friendship(user_id, friend_id)'),
      );
  }
  </code></pre>