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'),
|
'role' => new Role('CHILL_ACTIVITY_CREATE'),
|
||||||
'activityType' => $entity->getType(),
|
'activityType' => $entity->getType(),
|
||||||
'accompanyingPeriod' => $accompanyingPeriod,
|
'accompanyingPeriod' => $accompanyingPeriod,
|
||||||
|
'edit' => false
|
||||||
])->handleRequest($request);
|
])->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
@ -366,6 +367,7 @@ class ActivityController extends AbstractController
|
|||||||
'role' => new Role('CHILL_ACTIVITY_UPDATE'),
|
'role' => new Role('CHILL_ACTIVITY_UPDATE'),
|
||||||
'activityType' => $entity->getType(),
|
'activityType' => $entity->getType(),
|
||||||
'accompanyingPeriod' => $accompanyingPeriod,
|
'accompanyingPeriod' => $accompanyingPeriod,
|
||||||
|
'edit' => true
|
||||||
])->handleRequest($request);
|
])->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
@ -93,7 +93,7 @@ class ActivityType extends AbstractType
|
|||||||
/** @var \Chill\ActivityBundle\Entity\ActivityType $activityType */
|
/** @var \Chill\ActivityBundle\Entity\ActivityType $activityType */
|
||||||
$activityType = $options['activityType'];
|
$activityType = $options['activityType'];
|
||||||
|
|
||||||
if (!$activityType->isActive()) {
|
if (!$activityType->isActive() && $options['edit'] !== true) {
|
||||||
throw new \InvalidArgumentException('Activity type must be active');
|
throw new \InvalidArgumentException('Activity type must be active');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,9 @@ class ActivityType extends AbstractType
|
|||||||
if ($options['center']) {
|
if ($options['center']) {
|
||||||
$builder->add('scope', ScopePickerType::class, [
|
$builder->add('scope', ScopePickerType::class, [
|
||||||
'center' => $options['center'],
|
'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
|
$resolver
|
||||||
->setRequired(['center', 'role', 'activityType', 'accompanyingPeriod'])
|
->setRequired(['center', 'role', 'activityType', 'accompanyingPeriod', 'edit'])
|
||||||
->setAllowedTypes('center', ['null', 'Chill\MainBundle\Entity\Center'])
|
->setAllowedTypes('center', ['null', 'Chill\MainBundle\Entity\Center'])
|
||||||
->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role')
|
->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role')
|
||||||
->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class)
|
->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class)
|
||||||
->setAllowedTypes('accompanyingPeriod', [\Chill\PersonBundle\Entity\AccompanyingPeriod::class, 'null'])
|
->setAllowedTypes('accompanyingPeriod', [\Chill\PersonBundle\Entity\AccompanyingPeriod::class, 'null'])
|
||||||
|
->setAllowedTypes('edit', 'bool')
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user