symfony2 form multiple select with arraycollection symfony2 form multiple select with arraycollection symfony symfony

symfony2 form multiple select with arraycollection


For a choice of entities you should use the special choice field type 'entity' (see Symfony manual for entity field type). For an example see my answer to a similar question.If you get further errors you may also find this question on Role Interface and Manage Roles helpful.


for the fosuserbundle I do it like that:

        $builder->add('roles', 'choice', array(        'multiple' => true,        'choices' => array(            'ROLE_USER' => 'User',            'ROLE_AUTHOR' => 'Autor',            'ROLE_MODERATOR' => 'Moderator',            'ROLE_ADMIN' => 'Admin'        ),        'label' => 'Rollen',        'required' => true    ));