Form CollectionType with radio buttons fails after Symfony 2.7 upgrade -


getting below error..

an exception has been thrown during rendering of template ("the form's view data expected of type scalar, array or instance of \arrayaccess, instance of class proxies__cg__\bla\mybundle\entity\transporttype. can avoid error setting "data_class" option "proxies__cg__\bla\mybundle\entity\transporttype" or adding view transformer transforms instance of class proxies__cg__\bla\mybundle\entity\transporttype scalar, array or instance of \arrayaccess.") in mybundle:shipping:form.html.twig @ line 8.

$builder->add('variables','collection', array(             'type' => new abctype(),             'options'  => array(                 'required'  => true,                 ),             'constraints' => new notnull())); 

abctype.php

class abctype extends abstracttype {     /**      * build form      *      * @param formbuilder $builder      * @param array       $options      *      * @return void      */     public function buildform(formbuilderinterface $builder, array $options)     {          $builder->add('importance', null, array('empty_value'=>false,'expanded'=>true,                                 'required'=>true,'multiple'=>false,                                 'constraints' => new notnull()))             ->add('timespent', null, array(                                 'empty_value'=>false,'expanded'=>true,                                 'required'=>true,'multiple'=>false,                                 'constraints' => new notnull()                                 )             );     }      /**      * setdefaultoptions set default values      *      * @param optionsresolverinterface $resolver      */     public function setdefaultoptions(optionsresolverinterface $resolver)     {         $resolver->setdefaults(array(             'data_class' => 'demo\mybundle\entity\abc'         ));     }      /**      * getname return form name      * @return string      */     public function getname()     {         return 'demo_mybundle_abctype';     } } 

i fixed issue using below link....

https://github.com/symfony/symfony/issues/14877


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -