mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
option added to distinguish between edit and new action so that modification of activity with uactive type is possible
This commit is contained in:
parent
ddbd6a9f23
commit
b510d6a7f5
@ -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()) {
|
||||
|
@ -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')
|
||||
;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user