php - Symfony2 Form builder add entity 'Could not load type entity' -


i've created form type in symfony extends abstract type, , added fields using builder, no matter won't work!

class mytype extends abstracttype {     public function buildform(formbuilderinterface $builder, array $options)     {         $builder->add('name', 'text');         $builder->add('other', 'entity', array(             'data_class' => 'my\app\defaultbundle\entity\other'         ));     }      public function configureoptions(optionsresolver $resolver)     {         $resolver->setdefaults(array(             'runspeeds' => 'my\app\defaultbundle\entity\my',         ));     }      public function getname()     {         return 'my';     } } 

could not load type "entity" 500 internal server error - invalidargumentexception

"my" entity has column references id of "other" using foreign key constraint. want form have drop down in form "my" displays values "name" column in "other" entity using other.id -> my.other_id reference.

update

i have othertype (form type) , following work:

$builder>add('name', new othertype(), array(     'data_class' => 'my\app\defaultbundle\entity\other') ) 

but displays entire entity in form. want 1 field other entity display, , in dropdown choices

you didn't provide required option class.

as mentioned in documentation of entity field type

edit:

moreover have 2 syntax issues (";" missing)

$builder->add('name', 'text') $builder->add('other', 'entity', array(     'data_class' => 'my\app\defaultbundle\entity\other' )) 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -