diff --git a/src/Controller/Teamer/Profile/IndexController.php b/src/Controller/Teamer/Profile/IndexController.php index 9aa13a8..53e0d5c 100644 --- a/src/Controller/Teamer/Profile/IndexController.php +++ b/src/Controller/Teamer/Profile/IndexController.php @@ -53,7 +53,10 @@ class IndexController extends AbstractController // Validate teamer data to show missing data right away $errors = $this->validator->validate($teamer, null, ['profile_preflight']); - $form = $this->createForm(TeamerProfileType::class, $teamer, ['upload_session' => $uploadSession]); + $form = $this->createForm(TeamerProfileType::class, $teamer, [ + 'upload_session' => $uploadSession, + 'admin_mode' => $this->isGranted('IS_IMPERSONATOR'), + ]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { diff --git a/src/Controller/Teamer/Profile/SkillsController.php b/src/Controller/Teamer/Profile/SkillsController.php index e4454d4..ef1353f 100644 --- a/src/Controller/Teamer/Profile/SkillsController.php +++ b/src/Controller/Teamer/Profile/SkillsController.php @@ -59,7 +59,11 @@ class SkillsController extends AbstractController $selectableJobProfiles[$profile->getId()] = $requiredTrainingsSatisfied && $requiredLicensesSatisfied; } - $form = $this->createForm(TeamerJobProfileType::class, $teamer, ['job_profiles' => $jobProfiles, 'selectable_job_profiles' => $selectableJobProfiles]); + $form = $this->createForm(TeamerJobProfileType::class, $teamer, [ + 'job_profiles' => $jobProfiles, + 'selectable_job_profiles' => $selectableJobProfiles, + 'admin_mode' => $this->isGranted('IS_IMPERSONATOR'), + ]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { diff --git a/src/Form/TeamerJobProfileType.php b/src/Form/TeamerJobProfileType.php index 2609e52..c6d9615 100644 --- a/src/Form/TeamerJobProfileType.php +++ b/src/Form/TeamerJobProfileType.php @@ -18,7 +18,6 @@ class TeamerJobProfileType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { - $selectableProfiles = $options['selectable_job_profiles']; $builder ->add('jobProfiles', EntityType::class, [ 'label' => false, @@ -43,8 +42,12 @@ class TeamerJobProfileType extends AbstractType return $label; }, // Set disabled attribute on profiles that require a training or licenses the teamer doesn‘t have - 'choice_attr' => function($choice, string $key, mixed $value) use ($selectableProfiles) { - if (true === $selectableProfiles[$choice->getId()]) { + // unless in admin mode + 'choice_attr' => function($choice, string $key, mixed $value) use ($options) { + $selectableProfiles = $options['selectable_job_profiles']; + $isAdminMode = $options['admin_mode']; + + if (true === $isAdminMode || true === $selectableProfiles[$choice->getId()]) { return []; } @@ -80,6 +83,7 @@ class TeamerJobProfileType extends AbstractType 'data_class' => Teamer::class, 'job_profiles' => [], 'selectable_job_profiles' => [], + 'admin_mode' => false, 'anti_xss' => true, ]); }