title: Entity primary key inside symfony collection
body: <p>Im learning symfony 3 &amp; doctrine and i created a form with entity collection. Entities are Post and Tags with manyTomany relation. Main form is Post with collection of tags.
  I want to pass only IDs (primary key) of tags in my collection. In result i have only one field in tag form:</p>
  
  <pre><code>$builder-&gt;add('tagId');
  </code></pre>
  
  <p>I created autocomplete for it, thats why i need only primary key.
  After saving my form, doctrine create new tag entities with passed ids but i want to find those entities instead of creating new. Have no clue...</p>
  
  <p>I was trying to make it work inside my controller:</p>
  
  <pre><code>$formTags = $form-&gt;get('tag');
  foreach ($formTags-&gt;getData() as $key =&gt; $formTag)
  {
      // here i have new entities with id ;/
      if($formTag-&gt;getTagId())
      {
      // so i tryied to find them, and replace it
          $formTags-&gt;offsetSet($key, 
              array($this-&gt;getDoctrine()-&gt;getRepository('BlogBundle:Tag')
                            -&gt;find($formTag-&gt;getTagId())));
      }
  }
  </code></pre>
  
  <p>But symfony throw me exceptions, also with setData method. Cant change it after form is submitted. I hope you guys can help me!</p>
  
  <p>i was trying to make data transformer. Forget to mention :) Problem Was that my transformer change tagId field to tag object. In result i had tag object with new entity, and instead tagId value - there was another object inside, transformed. So dont work like expected for me. I think i should make transformer for collection field instead of tag id, but have no idea how make it work. I tryied to make "tag" field inside collection and transform it, but doctrine try always to get value from entity based on fields so no getTag() method found :) </p>