<p dir="auto">Updating to 2.7 breaks a few of my forms that use <code class="notranslate">choice_list</code> with an <code class="notranslate">ObjectChoiceList</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="'choice_list' =&gt; new ObjectChoiceList($choices, 'label', array(), null, 'value'),"><pre class="notranslate"><code class="notranslate">'choice_list' =&gt; new ObjectChoiceList($choices, 'label', array(), null, 'value'),
</code></pre></div>
<p dir="auto">results in:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="LogicException in Form.php line 374:
The form's view data is expected to be an instance of class Acme\Model\Choice, but is a(n) string. You can avoid this error by setting the &quot;data_class&quot; option to null or by adding a view transformer that transforms a(n) string to an instance of Acme\Model\Choice."><pre class="notranslate"><code class="notranslate">LogicException in Form.php line 374:
The form's view data is expected to be an instance of class Acme\Model\Choice, but is a(n) string. You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms a(n) string to an instance of Acme\Model\Choice.
</code></pre></div>
<p dir="auto">I understand that <code class="notranslate">choice_list</code> is deprecated, so I've tried using:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" 'choices' =&gt; $choices,
 'choices_as_values' =&gt; true,"><pre class="notranslate"><code class="notranslate"> 'choices' =&gt; $choices,
 'choices_as_values' =&gt; true,
</code></pre></div>
<p dir="auto">as well as using a <code class="notranslate">DefaultChoiceListFactory</code> as described in <a href="https://github.com/symfony/symfony/blob/2.7/UPGRADE-2.7.md">https://github.com/symfony/symfony/blob/2.7/UPGRADE-2.7.md</a>, but I'm not really getting anywhere.</p>
<p dir="auto">Is there documentation anywhere for how to use objects as choices in 2.7?</p>
<p dir="auto">Imagine this form:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="public function buildForm(FormBuilderInterface $builder, array $options)
{
        $builder-&gt;add('transportType', 'entity',
            array(
                'class' =&gt; 'MyBundle:TransportType',
                'property' =&gt; 'language.name',
                'expanded' =&gt; true,
                'query_builder' =&gt; function (EntityRepository $er) {
                    return $er-&gt;createQueryBuilder('e')
                        -&gt;join('e.language', 'l')
                        -&gt;orderBy('l.name', 'DESC');
                },
            )
        );
}

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
        $resolver-&gt;setDefaults(array(
            'data_class' =&gt; 'BLA\MyBundle\Form\Model\Shipping',
        ));
}"><pre class="notranslate"><span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">buildForm</span>(<span class="pl-smi"><span class="pl-smi">FormBuilderInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>builder</span>, <span class="pl-smi">array</span> <span class="pl-s1"><span class="pl-c1">$</span>options</span>)
{
        <span class="pl-s1"><span class="pl-c1">$</span>builder</span>-&gt;<span class="pl-en">add</span>(<span class="pl-s">'transportType'</span>, <span class="pl-s">'entity'</span>,
            <span class="pl-en">array</span>(
                <span class="pl-s">'class'</span> =&gt; <span class="pl-s">'MyBundle:TransportType'</span>,
                <span class="pl-s">'property'</span> =&gt; <span class="pl-s">'language.name'</span>,
                <span class="pl-s">'expanded'</span> =&gt; <span class="pl-c1">true</span>,
                <span class="pl-s">'query_builder'</span> =&gt; <span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">EntityRepository</span></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">'e'</span>)
                        -&gt;<span class="pl-en">join</span>(<span class="pl-s">'e.language'</span>, <span class="pl-s">'l'</span>)
                        -&gt;<span class="pl-en">orderBy</span>(<span class="pl-s">'l.name'</span>, <span class="pl-s">'DESC'</span>);
                },
            )
        );
}

<span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">setDefaultOptions</span>(<span class="pl-smi"><span class="pl-smi">OptionsResolverInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>resolver</span>)
{
        <span class="pl-s1"><span class="pl-c1">$</span>resolver</span>-&gt;<span class="pl-en">setDefaults</span>(<span class="pl-en">array</span>(
            <span class="pl-s">'data_class'</span> =&gt; <span class="pl-s">'BLA\MyBundle\Form\Model\Shipping'</span>,
        ));
}</pre></div>
<p dir="auto">After upgrading to Symfony 2.7, the form throws the following exception:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="An exception has been thrown during the rendering of a template (&quot;The form's view data is expected to be of type scalar, array or an instance of \ArrayAccess, but is an instance of class Proxies\__CG__\BLA\MyBundle\Entity\TransportType. You can avoid this error by setting the &quot;data_class&quot; option to &quot;Proxies\__CG__\BLA\MyBundle\Entity\TransportType&quot; or by adding a view transformer that transforms an instance of class Proxies\__CG__\BLA\MyBundle\Entity\TransportType to scalar, array or an instance of \ArrayAccess.&quot;) in MyBundle:Shipping:form.html.twig at line 8."><pre class="notranslate"><code class="notranslate">An exception has been thrown during the rendering of a template ("The form's view data is expected to be of type scalar, array or an instance of \ArrayAccess, but is an instance of class Proxies\__CG__\BLA\MyBundle\Entity\TransportType. You can avoid this error by setting the "data_class" option to "Proxies\__CG__\BLA\MyBundle\Entity\TransportType" or by adding a view transformer that transforms an instance of class Proxies\__CG__\BLA\MyBundle\Entity\TransportType to scalar, array or an instance of \ArrayAccess.") in MyBundle:Shipping:form.html.twig at line 8.
</code></pre></div>
<p dir="auto">Setting the <code class="notranslate">data_class</code> seems to work but I wonder why this has not been documented in the upgrade file?</p>