feat: admin mode for teamer profile form to override disabled fields

This commit is contained in:
Björn Fromme committed 2024-11-25 15:34:45 +01:00
1 parent b405643732
commit febf90c0db
3 files changed
+16 -5

No files matched your search

+7 -3
View File
@@ -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,
]);
}