Dit is wat ik deed om van het probleem af te komen,
Definieer Rollen in /app/config/security.yml zoals hieronder,
role_hierarchy:
ROLE_ADMIN: [ROLE_ADMIN]
ROLE_SUPER_ADMIN: [ROLE_SUPER_ADMIN, ROLE_ALLOWED_TO_SWITCH]
ROLE_TEACHER: [ROLE_TEACHER]
ROLE_STUDENT: [ROLE_STUDENT]
ROLE_PARENT: [ROLE_PARENT]
in de Controller, haal de rollen op uit de /app/config/security.yml met behulp van de volgende code
$roles = $this->getParameter('security.role_hierarchy.roles');
en dit is de code voor rollen in het formuliertype,
$roles = $this->getParent('security.role_hierarchy.roles');
en dan in het vormtype, (hier is het multi-select)
->add('roles', ChoiceType::class, array(
'attr' => array('class' => 'form-control',
'style' => 'margin:5px 0;'),
'choices' =>
array
(
'ROLE_ADMIN' => array
(
'Yes' => 'ROLE_ADMIN',
),
'ROLE_TEACHER' => array
(
'Yes' => 'ROLE_TEACHER'
),
'ROLE_STUDENT' => array
(
'Yes' => 'ROLE_STUDENT'
),
'ROLE_PARENT' => array
(
'Yes' => 'ROLE_PARENT'
),
)
,
'multiple' => true,
'required' => true,
)
)
Bewerken Gebruikersrollen moeten worden gedefinieerd in /app/config/security.yml zoals hieronder
role_hierarchy:
ROLE_ADMIN: [ROLE_ADMIN]
ROLE_SUPER_ADMIN: [ROLE_SUPER_ADMIN, ROLE_ALLOWED_TO_SWITCH]
ROLE_TEACHER: [ROLE_TEACHER]
ROLE_STUDENT: [ROLE_STUDENT]
ROLE_PARENT: [ROLE_PARENT]