symfony - symfony2 form multiple select with arraycollection -


i create form edit users. users , roles connected manytomany. in userusers entity have $roles variable arraycollection:

public function __construct() {     $this->roles = new arraycollection(); } 

on form add roles users via multiple select form element. in user form:

public function buildform( formbuilderinterface $builder, array $options ) {     $builder->add( 'username' )             ->add( 'password', 'repeated', array(                      'type' => 'password',                     'mapped' => false,                     'required' => false,                     'first_options' => array(                              'label' => 'password' ),                     'second_options' => array(                              'label' => 'repeat password' ) ) )             ->add( 'roles', 'choice', array(                      'mapped' => false,                     'multiple' => true ) ); } 

now multiple select empty.

if turn mapped true, got error message:

userroles not converted int in...

i've tried lots of ways, not solve problem correctly.

for choice of entities should use special choice field type 'entity' (see symfony manual entity field type). example see answer similar question. if further errors may find question on role interface , manage roles helpful.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -