Closed
Description
Imagine this form:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('transportType', 'entity',
array(
'class' => 'MyBundle:TransportType',
'property' => 'language.name',
'expanded' => true,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('e')
->join('e.language', 'l')
->orderBy('l.name', 'DESC');
},
)
);
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'BLA\MyBundle\Form\Model\Shipping',
));
}
After upgrading to Symfony 2.7, the form throws the following exception:
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.
Setting the data_class
seems to work but I wonder why this has not been documented in the upgrade file?