title: Remove null values coming from empty collection form item
body: <p>I'm trying to implement a ManyToMany relation in a form between 2 entities (say, Product and Category to make simpe) and use the method described in the docs with prototype and javascript (<a href="http://symfony.com/doc/current/cookbook/form/form_collections.html" rel="nofollow">http://symfony.com/doc/current/cookbook/form/form_collections.html</a>).</p>
  
  <p>Here is the line from ProductType that create the category collection :</p>
  
  <pre><code>$builder-&gt;add('categories', 'collection', array(
                     'type' =&gt; 'entity',
                     'options' =&gt; array(
                          'class' =&gt; 'AppBundle:Category',
                          'property'=&gt;'name',
                          'empty_value' =&gt; 'Select a category',
                          'required' =&gt; false),
                     'allow_add' =&gt; true,
                     'allow_delete' =&gt; true,
                ));
  </code></pre>
  
  <p>When I had a new item, a new select appear set to the empty value 'Select a category'. The problem is that if I don't change the empty value, it is sent to the server and after a $form->bind() my Product object get some null values in the $category ArrayCollection.</p>
  
  <p>I first though to test the value in the setter in Product entity, and add 'by_reference'=>false in the ProductType, but in this case I get an exception stating that null is not an instance of Category.</p>
  
  <p>How can I make sure the empty values are ignored ?</p>