diff --git a/src/Bundle/ChillActivityBundle/CHANGELOG.md b/src/Bundle/ChillActivityBundle/CHANGELOG.md index 871ead4bd..6261aa1db 100644 --- a/src/Bundle/ChillActivityBundle/CHANGELOG.md +++ b/src/Bundle/ChillActivityBundle/CHANGELOG.md @@ -27,3 +27,4 @@ Version 1.5.5 ============= - [activity] replace dropdown for selecting reasons and use chillEntity for reason rendering +- fix bug: error when trying to edit activity of which the type has been deactivated diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index a454626b7..8a4a228eb 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -174,6 +174,10 @@ class ActivityController extends AbstractController $activityType = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class) ->find($activityType_id); + if (isset($activityType) && !$activityType->isActive()) { + throw new \InvalidArgumentException('Activity type must be active'); + } + $activityData = null; if ($request->query->has('activityData')) { $activityData = $request->query->get('activityData'); diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 8c8fb45a9..5a711408c 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -93,15 +93,13 @@ class ActivityType extends AbstractType /** @var \Chill\ActivityBundle\Entity\ActivityType $activityType */ $activityType = $options['activityType']; - if (!$activityType->isActive()) { - throw new \InvalidArgumentException('Activity type must be active'); - } - // TODO revoir la gestion des center au niveau du form des activité. 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 ]); }