work on create calendar

This commit is contained in:
2022-05-13 13:49:24 +02:00
parent 7859439f0b
commit 4be3efc619
10 changed files with 128 additions and 44 deletions

View File

@@ -70,6 +70,7 @@ class CalendarType extends AbstractType
if ($options['data'] instanceof Calendar && $options['data']->getId() === null) {
$builder->add('mainUser', PickUserDynamicType::class, [
'multiple' => false,
'required' => true,
'help' => 'chill_calendar.form.The main user is mandatory. He will organize the appointment.',
]);
@@ -192,26 +193,6 @@ class CalendarType extends AbstractType
return $this->om->getRepository(Location::class)->findOneBy(['id' => (int) $id]);
}
));
$builder->add('invites', HiddenType::class);
$builder->get('invites')
->addModelTransformer(new CallbackTransformer(
static function (iterable $usersAsIterable): string {
$userIds = [];
foreach ($usersAsIterable as $value) {
$userIds[] = $value->getId();
}
return implode(',', $userIds);
},
function (?string $usersAsString): array {
return array_map(
fn (string $id): ?Invite => $this->om->getRepository(Invite::class)->findOneBy(['id' => (int) $id]),
explode(',', $usersAsString)
);
}
));
}
public function configureOptions(OptionsResolver $resolver)