title: Creating collection of read-only entities in Symfony2
body: <p>My question is about creating collection of entities. I know about "<a href="http://symfony.com/doc/current/cookbook/form/form_collections.html" rel="nofollow">How To Embed Collection Forms</a>" and successfully used it. But in this case I have:</p>
  
  <p><strong>Simple class</strong></p>
  
  <pre><code>class Thing
  {
    /**              
    * @ORM\ManyToMany(targetEntity="DicStyle", mappedBy="things")
    * ....
    */
    protected $styles;   
  
    public function __construct()
    {
       $this-&gt;styles = new ArrayCollection();
    } 
  }
  </code></pre>
  
  <p><strong>Dictionary of styles</strong></p>
  
  <pre><code>class DicStyle 
  {
      ..... 
  }
  </code></pre>
  
  <p>I don't need to create form for DicStyle objects, because this is read only objects = dictionary (unchangeable). So, I want to create a form with something like this:</p>
  
  <pre><code>$builder-&gt;add('styles', 'collection', array(
      'type'   =&gt; 'entity', 'options' =&gt; array(
          'class' =&gt; 'MyEntityBundle:DicStyle'
          )
   ))         
  </code></pre>
  
  <p>Of course it's pseudo-code. I can not imagine how to implement it.</p>
  
  <p><strong>The result</strong></p>
  
  <p>Suppose, I have:</p>
  
  <ul>
  <li>Table "Thing" with one row (id = 1).</li>
  <li>Table "DicStyle" with 6 rows (id = from 1 to 6).</li>
  <li>Table "mtm_thing_dicstyle" (many-to-many table)</li>
  </ul>
  
  <p>In the form, I choose two DicStyle (id=3, id=5) for the Thing. So, the mtm_thing_dicstyle contains:</p>
  
  <pre><code>thing_id     dicstyle_id
  --------     ------------
      1            3
      1            5
  </code></pre>