title: Sonata Admin edit form many to many not working - symfony2.1.6
body: <p>I am having a problem with implementing the many to many relationship in the sonata admin edit form, with the following structure.</p>
  
  <pre><code>purchase (id, total_price, discount, created_at)
  purchase_product (purchase_id, product_id, quantity)
  product (id, title, desc, price, thumbnail, created_at)
  </code></pre>
  
  <p>I have seen many threads and have tried the solutions listed in them. I have tried </p>
  
  <pre><code>-&gt;add('products', 'sonata_type_model', array('by_reference' =&gt; false))
  </code></pre>
  
  <p>I get the following error</p>
  
  <pre><code>No entity manager defined for class Doctrine\ORM\PersistentCollection 
  </code></pre>
  
  <p>Then when i couldn't find a way to solve this, I switched to </p>
  
  <pre><code>-&gt;add('products', 'sonata_type_collection', array(), array('edit' =&gt; 'inline', 'inline' =&gt; 'table')
  </code></pre>
  
  <p>I got the following error</p>
  
  <pre><code>INVALID MODE type : sonata_type_collection - mapping : 8 
  </code></pre>
  
  <p>I am also unable to figure out how to get and display the quantity from the purchase_product table. </p>
  
  <p>Any pointers and help is highly appreciated.</p>