Symfony Object of class Closure could
bonjour mes amis,
j'ai ce probléme lorsque j'affiche le formulaire du création du groupe, j'en sais pas comment le résoudre. j'utilise la version 2.7
** l'erreur:
Catchable Fatal Error: Object of class Closure could not be converted to string
500 Internal Server Error - ContextErrorException
Stack Trace
in vendor/symfony/symfony/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php at line 166 -
// If "choice_label" is set to false and "expanded" is true, the value false
// should be passed on to the "label" option of the checkboxes/radio buttons
$dynamicLabel = call_user_func($label, $choice, $key, $value);
$label = false === $dynamicLabel ? false : (string) $dynamicLabel;
}
$view = new ChoiceView(
-Voilà mon GroupsType:
class GroupsType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('image', new ImagesType())
->add('name_groups','text',array('required' => true, 'attr' => array('placeholder' => 'Nom du groupe')))
->add('role', new RolesType())
;
}
-Voilà mon RoleType:
lass RolesType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('groups', 'choice', array(
'choices' => array(
'class' => 'GroupsBundle:Roles',
'query_builder' => function(EntityRepository $er)
{
return $er->createQueryBuilder('r')
->orderBy('r.id', 'ASC');
},
'required' => false,
'multiple' => false,
'expanded' => false,
'placeholder' => 'Choisir le role du votre groupe'
)
)
)
->add('permissions_role','entity',array(
'class' => 'GroupsBundle:Permissions',
'multiple' => true,
'expanded' => true,
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('u')
->orderBy('u.name_permissions', 'ASC');
},
'required' => true
)
)
;
}
Merci d'avance ;)