0

I’m using the latest Symfony 4 bundle with security package installed. As I use an admin page for my content I need to login of course and so I generated, how I learned it, an user and class entity with an manyToMany relationship. This works well for creating a user and logging in and out, but unfortunately not for modifying a user.

I’m always getting an error about the roles as for edit the field is first not a role entity array entry but a simply array and so I can’t save the user. There is no special user bundle or so installed. When I delete the old entry from the database it works as there than exists no old value.

I also tried with $userid->removeRole($roleRepository->findOneByLabel('ROLE_USER')); at the beginning but than I also get an error that it must be an instance of the role entity. Does anyone have any idea how I could resolve this? Or has an example code where I could check myself?

ssuperczynski
  • 3,190
  • 3
  • 44
  • 61
  • Tip: Create const for static params as 'ROLE_USER'. You can create those constants in user entity, so you can do this: $userid->removeRole($roleRepository->findOneByLabel(User::ROLE_USER)); instead this: $userid->removeRole($roleRepository->findOneByLabel('ROLE_USER')); – AythaNzt Oct 22 '18 at 10:44

1 Answers1

0

I think for user manipulation this bundle is better. You can try.

https://symfony.com/doc/master/bundles/EasyAdminBundle/integration/fosuserbundle.html

Mert Simsek
  • 700
  • 7
  • 12