vue_activity location: add NewLocation fields, submit activity form with hidden field (+)

This commit is contained in:
2021-10-15 09:09:47 +02:00
parent 4d4662a634
commit e6845326d7
9 changed files with 175 additions and 11 deletions

View File

@@ -6,6 +6,7 @@ use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Entity\ActivityPresence;
use Chill\ActivityBundle\Entity\ActivityReason;
use Chill\DocStoreBundle\Form\StoredObjectType;
use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Form\Type\ChillCollectionType;
use Chill\MainBundle\Form\Type\CommentType;
use Chill\PersonBundle\Entity\Person;
@@ -303,7 +304,20 @@ class ActivityType extends AbstractType
}
if ($activityType->isVisible('location')) {
$builder->add('location', HiddenType::class);
$builder->add('location', HiddenType::class)
->get('location')
->addModelTransformer(new CallbackTransformer(
function (?Location $location): string {
if (null === $location) {
return '';
}
return $location->getId();
},
function (?string $id): Location {
return $this->om->getRepository(Location::class)->findOneBy(['id' => (int) $id]);
}
))
;
}
if ($activityType->isVisible('emergency')) {