<p dir="auto">When you use the EntityType without a form builder option, then when you bind it, the whole collection is read from the database. In my case, this means hydrating a table of thousands of records, which of course is both time and memory consuming.</p>
<p dir="auto">Standard usage of the form would prevent this behaviour, because it'd also mean rendering a select with the same thousands of options when you do a createView call, however, in my case I'm not using the FormView. I use the Form component to deserialize a JSON request. I was able to fix this issue with the following change in my Type:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$builder-&gt;add('worker'); // automatically turned into an entity type"><pre class="notranslate"><span class="pl-s1"><span class="pl-c1">$</span>builder</span>-&gt;<span class="pl-en">add</span>(<span class="pl-s">'worker'</span>); <span class="pl-c">// automatically turned into an entity type</span></pre></div>
<p dir="auto">to</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$builder-&gt;add('worker', null, array('query_builder' =&gt; function ($er) {
    return $er-&gt;createQueryBuilder('w');
})));"><pre class="notranslate"><span class="pl-s1"><span class="pl-c1">$</span>builder</span>-&gt;<span class="pl-en">add</span>(<span class="pl-s">'worker'</span>, <span class="pl-c1">null</span>, <span class="pl-en">array</span>(<span class="pl-s">'query_builder'</span> =&gt; <span class="pl-k">function</span> (<span class="pl-s1"><span class="pl-c1">$</span>er</span>) {
    <span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span>er</span>-&gt;<span class="pl-en">createQueryBuilder</span>(<span class="pl-s">'w'</span>);
})));</pre></div>
<p dir="auto">However, adding this query builder just to prevent the ChoiceList from loading all the entities looks hackish to me.</p>
<p dir="auto">The PR <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1396137" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/1951" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/1951/hovercard" href="https://github.com/symfony/symfony/pull/1951">#1951</a> "[Form] Added form type "entity_identifier" has been open for ages now. The number of supporters alone justifies its existence, but I think the requested functionality should be solved in a more generic way.</p>
<p dir="auto">I think that we should add two new options <code class="notranslate">widget</code> and <code class="notranslate">delimiter</code> to ChoiceType.</p>
<ul dir="auto">
<li><code class="notranslate">widget</code> can be one of the values <code class="notranslate">select</code>, <code class="notranslate">checkbox</code>, <code class="notranslate">radio</code> and <code class="notranslate">text</code></li>
<li><code class="notranslate">delimiter</code> can be any single character</li>
</ul>
<p dir="auto">The option <code class="notranslate">expanded</code> would be deprecated. I think having a <code class="notranslate">widget</code> and an <code class="notranslate">expanded</code> option at the same time is inconsistent.</p>
<p dir="auto">Behavior:</p>
<ul dir="auto">
<li><code class="notranslate">widget = 'select'</code>: This is equivalent to <code class="notranslate">expanded = false</code> right now.</li>
<li><code class="notranslate">widget = 'checkbox'</code>: <code class="notranslate">multiple</code> must not be set to false. Otherwise equivalent to <code class="notranslate">expanded = true</code>.</li>
<li><code class="notranslate">widget = 'radio'</code>: <code class="notranslate">multiple</code> must not be set to true. Otherwise equivalent to <code class="notranslate">expanded = true</code>.</li>
<li><code class="notranslate">widget = 'text'</code>: A text input is shown.
<ul dir="auto">
<li>if <code class="notranslate">multiple</code> is false, the input must equal one of the predefined choices.</li>
<li>if <code class="notranslate">multiple</code> is true, the input is split by the character defined in <code class="notranslate">delimiter</code> (a comma by default), then each value is trimmed (unless <code class="notranslate">trim</code> is false). Each resulting input must equal one of the predefined choices.</li>
</ul>
</li>
</ul>