Allow the selection of multiple centers to create multiple groupcenters at once

This commit is contained in:
2024-11-07 18:49:07 +01:00
parent 63fc4f1089
commit 0f1604817b
2 changed files with 23 additions and 20 deletions

View File

@@ -64,10 +64,19 @@ class UserController extends CRUDController
$form->handleRequest($request);
if ($form->isValid()) {
$groupCenter = $this->getPersistedGroupCenter(
$form[self::FORM_GROUP_CENTER_COMPOSED]->getData()
);
$user->addGroupCenter($groupCenter);
$formData = $form[self::FORM_GROUP_CENTER_COMPOSED]->getData();
$selectedCenters = $formData['center'];
foreach ($selectedCenters as $center) {
$groupCenter = new GroupCenter();
$groupCenter->setCenter($center);
$groupCenter->setPermissionsGroup($formData['permissionsgroup']);
$user->addGroupCenter($groupCenter);
$em->persist($groupCenter);
}
if (0 === $this->validator->validate($user)->count()) {
$em->flush();