<p dir="auto">in my form builder I do:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$builder
        -&gt;add('debugDate', DateType::class, array(
            'label' =&gt; 'label.debug_date',
            'widget' =&gt; 'single_text',
            'required' =&gt; false,
            'empty_data' =&gt; null,
            'attr' =&gt; array('data-datepicker'=&gt;1),
        ))
        -&gt;add('debugNumber', NumberType::class, array(
            'label'    =&gt; 'label.debug_number',
            'required' =&gt; false,
            'empty_data' =&gt; null,
            'scale' =&gt; 2));"><pre class="notranslate"><code class="notranslate">$builder
        -&gt;add('debugDate', DateType::class, array(
            'label' =&gt; 'label.debug_date',
            'widget' =&gt; 'single_text',
            'required' =&gt; false,
            'empty_data' =&gt; null,
            'attr' =&gt; array('data-datepicker'=&gt;1),
        ))
        -&gt;add('debugNumber', NumberType::class, array(
            'label'    =&gt; 'label.debug_number',
            'required' =&gt; false,
            'empty_data' =&gt; null,
            'scale' =&gt; 2));
</code></pre></div>
<p dir="auto">Enttiy Code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/**
 * @var \DateTime
 * @ORM\Column(name=&quot;debug_date&quot;, type=&quot;datetime&quot;, nullable=true)
 */
private $debugDate;
/**
 * @var \DateTime
 * @ORM\Column(name=&quot;debug_number&quot;, type=&quot;datetime&quot;, nullable=true)
 */
private $debugNumber;"><pre class="notranslate"><code class="notranslate">/**
 * @var \DateTime
 * @ORM\Column(name="debug_date", type="datetime", nullable=true)
 */
private $debugDate;
/**
 * @var \DateTime
 * @ORM\Column(name="debug_number", type="datetime", nullable=true)
 */
private $debugNumber;
</code></pre></div>
<p dir="auto">Apparently <code class="notranslate">'empty_data' =&gt; null</code> does not work as expected, since vars.value outputs an empty strring. Why is that?</p>
<p dir="auto">Is there a wworkaround for this issue? My project deadline is in a couple of days:(<br>
I'm reporting this code in a simplified way, real fields are all in embedded forms, if that is of any matter.<br>
Symfony version 3.0.3</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/1181094/14002350/bb666a40-f14b-11e5-8de8-563b29489259.png"><img src="https://cloud.githubusercontent.com/assets/1181094/14002350/bb666a40-f14b-11e5-8de8-563b29489259.png" alt="screenshot_1" style="max-width: 100%;"></a><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/1181094/14002351/bb6d19da-f14b-11e5-94e6-24c7109136c5.png"><img src="https://cloud.githubusercontent.com/assets/1181094/14002351/bb6d19da-f14b-11e5-94e6-24c7109136c5.png" alt="screenshot_2" style="max-width: 100%;"></a></p>
<p dir="auto">This one is a bit hard to explain, but I'll try my best.</p>
<p dir="auto">PR#3239 brought proper handling of collections, but it doesn't work as expected. I've traced this only for blank collection, but this is probably the same or similar when you go and edit existing one.<br>
My collection object is having duplicates. And if I take a look at the memory addresses of those duplicates with the debugger, I can see that the same objects are added twice as they reside on the same address.</p>
<p dir="auto">It seems, that the data is bind to the collection twice, first in the form's bind() method and then once again in MergeCollectionListener.</p>
<p dir="auto">Looking at the $originalData when onBindNormData is called in<br>
<a href="https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php#L142">https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php#L142</a><br>
I can see, that $originalData already contains the whole collection that came in through the request.</p>
<p dir="auto">Later down the code calls add* method and adds the same objects.<br>
Now the problem is not visible if all you do with the data is just call $em-&gt;persist($form-&gt;getData()<br>
as doctrine will silently handle this, but if you need to traverse the collection and do some calculations<br>
on it before persisting, then you have the problem as you'll do the whatever you want to do twice.</p>