public function onPreSetData(FormEvent $event)
    {
        $form = $event->getForm();
        if ($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) {
            $roles = [
                'User' => 'ROLE_USER',
                'Admin' => 'ROLE_ADMIN',
                'Super admin' => 'ROLE_SUPER_ADMIN',
            ];
            $form
                ->add(
                    'roles',
                    ChoiceType::class,
                    [
                        'label' => 'Roles',
                        'required' => true,
                        'expanded' => true,
                        'multiple' => true,
                        'choices' => $roles,
                    ]
                );
        }
    }
public function onPreSetData(FormEvent $event)
    {
        $form = $event->getForm();
        if ($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) {
            $roles = [
                'User' => 'ROLE_USER',
                'Admin' => 'ROLE_ADMIN',
                'Super admin' => 'ROLE_SUPER_ADMIN',
            ];
            $form
                ->add(
                    'roles',
                    ChoiceType::class,
                    [
                        'label' => 'Roles',
                        'required' => true,
                        'expanded' => true,
                        'multiple' => true,
                        'choices' => $roles,
                    ]
                );
        }
    }
public function onPreSetData ( FormEvent $ event ) { $ form = $ event -> getForm ( ) ; if ( $ this -> authorizationChecker -> isGranted ( 'ROLE_SUPER_ADMIN' ) ) { $ roles = [ 'User' => 'ROLE_USER' , 'Admin' => 'ROLE_ADMIN' , 'Super admin' => 'ROLE_SUPER_ADMIN' , ] ; $ form -> add ( 'roles' , ChoiceType :: class , [ 'label' => 'Roles' , 'required' => true , 'expanded' => true , 'multiple' => true , 'choices' => $ roles , ] ) ; } }
Set appropriate field elements in form
@param FormEvent $event
Set appropriate field elements in form