Reputation: 5643
I am using symfony and FosUserBUndle
I have made the simple form and its working fine
But i am not able to render the roles
defined in FOS User.php
https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Model/User.php#L113
if i do
->add('roles', 'text')
then i get this error
Notice: Array to string conversion in /var/www/html/symfony/app/cache/dev/twig/86/d9/65467411897d4c5c4ef7c0a4bb1a3d4efd01b5d7b4d913636761fd36ee9e.php line 158
Upvotes: 0
Views: 781
Reputation: 2059
Roles are stored as an array in database. For example:
a:2:{i:0;s:10:"ROLE_ADMIN";i:1;s:9:"ROLE_NEWS";}
So you can not render array as a text. Try to use choice option, where 'choices' is your array with roles:
->add('roles', 'choice', array(
'choices' => array('ROLE_ADMIN' => 'ROLE_USER', 'ROLE_ADMIN' => 'ROLE_ADMIN'),
'required' => false,
));
Upvotes: 2