diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index a454626b7..80bf8bb04 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -256,6 +256,7 @@ class ActivityController extends AbstractController 'role' => new Role('CHILL_ACTIVITY_CREATE'), 'activityType' => $entity->getType(), 'accompanyingPeriod' => $accompanyingPeriod, + 'edit' => false ])->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -366,6 +367,7 @@ class ActivityController extends AbstractController 'role' => new Role('CHILL_ACTIVITY_UPDATE'), 'activityType' => $entity->getType(), 'accompanyingPeriod' => $accompanyingPeriod, + 'edit' => true ])->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 8c8fb45a9..3906fadd6 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -93,7 +93,7 @@ class ActivityType extends AbstractType /** @var \Chill\ActivityBundle\Entity\ActivityType $activityType */ $activityType = $options['activityType']; - if (!$activityType->isActive()) { + if (!$activityType->isActive() && $options['edit'] !== true) { throw new \InvalidArgumentException('Activity type must be active'); } @@ -101,7 +101,9 @@ class ActivityType extends AbstractType if ($options['center']) { $builder->add('scope', ScopePickerType::class, [ 'center' => $options['center'], - 'role' => $options['role'] + 'role' => $options['role'], + // TODO make required again once scope and rights are fixed + 'required' => false ]); } @@ -376,11 +378,12 @@ class ActivityType extends AbstractType ]); $resolver - ->setRequired(['center', 'role', 'activityType', 'accompanyingPeriod']) + ->setRequired(['center', 'role', 'activityType', 'accompanyingPeriod', 'edit']) ->setAllowedTypes('center', ['null', 'Chill\MainBundle\Entity\Center']) ->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role') ->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class) ->setAllowedTypes('accompanyingPeriod', [\Chill\PersonBundle\Entity\AccompanyingPeriod::class, 'null']) + ->setAllowedTypes('edit', 'bool') ; }