User table with 'roles' column with type json (roles - longtext - not null - comment '(DC2Type:json)');
Trying to save User via Sonata Admin tool and get the error Expected argument of type "array", "App\\UserModule\\Entity\\Enum\\UserRole" given at property path "roles"
.
protected function configureFormFields(FormMapper $form): void
{
$form->add('roles', EnumType::class, ['class' => UserRole::class]);
}
Form field is correctly displayed, but handling post request - got error. Creating user via console command works nice, so this is only about Sonata stuff
One of the way it can be done - use ChoiceType with 'multiple' setting
$form->add('roles', ChoiceType::class, [
'choices' => $roles,
'multiple' => true
]);