<p dir="auto">When an empty array is bound to the entity type (multiple: true), an error raises.</p>
<p dir="auto">It comes from the ORMQueryBuilderLoader.php when it loads entities:</p>
<p dir="auto">-&gt;setParameter($parameter, $values, Connection::PARAM_STR_ARRAY)</p>
<p dir="auto">The test case here:</p>
<p dir="auto"><a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/vlechemin/symfony/commit/2b02323637a425aefa0b69879d8135fdf0b3ddd7/hovercard" href="https://github.com/vlechemin/symfony/commit/2b02323637a425aefa0b69879d8135fdf0b3ddd7">vlechemin@<tt>2b02323</tt></a></p>
<p dir="auto">This is my form element:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$form-&gt;add($this-&gt;factory-&gt;createNamed('entity', 'job', null, array(
    'class' =&gt; 'PDB\PlanningBundle\Entity\Job',
    'property' =&gt; 'name',
    'required' =&gt; false,
    'multiple' =&gt; true,
    'query_builder' =&gt; function(JobRepository $er) use ($project) {
  ..."><pre class="notranslate"><code class="notranslate">$form-&gt;add($this-&gt;factory-&gt;createNamed('entity', 'job', null, array(
    'class' =&gt; 'PDB\PlanningBundle\Entity\Job',
    'property' =&gt; 'name',
    'required' =&gt; false,
    'multiple' =&gt; true,
    'query_builder' =&gt; function(JobRepository $er) use ($project) {
  ...
</code></pre></div>
<p dir="auto">If there is is nothing selected in this choice field, the field name isn't submitted and <code class="notranslate">null</code> is bound to the field. All leads to the following stack trace:<br>
<a href="https://gist.github.com/1903637">https://gist.github.com/1903637</a></p>
<p dir="auto">In my opinion this is a problem of <code class="notranslate">ChoicesToValuesTransformer</code> in <code class="notranslate">reverseTransform</code> method where it should be</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="if (empty($array)) {
    return array();
}"><pre class="notranslate"><code class="notranslate">if (empty($array)) {
    return array();
}
</code></pre></div>
<p dir="auto">instead of</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="if (null === $array) {
    return array();
}"><pre class="notranslate"><code class="notranslate">if (null === $array) {
    return array();
}
</code></pre></div>
<p dir="auto">and I'd add this to the tests:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="public function testReverseTransformEmptyArray()
{
    $this-&gt;assertSame(array(), $this-&gt;transformer-&gt;reverseTransform(array()));
}"><pre class="notranslate"><code class="notranslate">public function testReverseTransformEmptyArray()
{
    $this-&gt;assertSame(array(), $this-&gt;transformer-&gt;reverseTransform(array()));
}
</code></pre></div>
<p dir="auto">This fixes my problem at least.<br>
Do you agree? Then I'd submit a patch. How to add a pull request to this ticket?</p>