fix display of checkbox field in user form

This commit is contained in:
Julie Lenaerts 2022-03-10 10:38:01 +01:00
parent 3ebeda9840
commit 0fc3c2eb1f
2 changed files with 12 additions and 15 deletions

View File

@ -225,10 +225,7 @@ class User implements AdvancedUserInterface
public function getRoles(): array
{
$roles = $this->roles;
$roles[] = 'ROLE_USER';
return $roles;
return array_unique($this->roles);
}
public function getSalt(): ?string

View File

@ -105,17 +105,17 @@ class UserType extends AbstractType
},
]);
$builder->get('roles')
->addModelTransformer(new CallbackTransformer(
function ($rolesArray) {
// transform the array to a string
return count($rolesArray)? $rolesArray[0]: null;
},
function ($rolesString) {
// transform the string back to an array
return [$rolesString];
}
));
// $builder->get('roles')
// ->addModelTransformer(new CallbackTransformer(
// function ($rolesArray) {
// // transform the array to a string
// return count($rolesArray)? $rolesArray[0]: null;
// },
// function ($rolesString) {
// // transform the string back to an array
// return [$rolesString];
// }
// ));
if ($options['is_creation']) {
$builder->add('plainPassword', RepeatedType::class, [