WIP: create and edit calendar

This commit is contained in:
2022-05-11 17:47:33 +02:00
parent f4b1a25a67
commit c60a54eb39
11 changed files with 217 additions and 69 deletions

View File

@@ -18,6 +18,7 @@ use Chill\CalendarBundle\Entity\Invite;
use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\Type\CommentType;
use Chill\MainBundle\Form\Type\PickUserDynamicType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
@@ -67,22 +68,12 @@ class CalendarType extends AbstractType
'expanded' => true,
]);
$builder->add('mainUser', HiddenType::class);
$builder->get('mainUser')
->addModelTransformer(new CallbackTransformer(
static function (?User $user): int {
if (null !== $user) {
$res = $user->getId();
} else {
$res = -1; //TODO cannot be null in any ways...
}
return $res;
},
function (?int $userId): User {
return $this->om->getRepository(user::class)->findOneBy(['id' => (int) $userId]);
}
));
if ($options['data'] instanceof Calendar && $options['data']->getId() === null) {
$builder->add('mainUser', PickUserDynamicType::class, [
'required' => true,
'help' => 'chill_calendar.form.The main user is mandatory. He will organize the appointment.',
]);
}
$builder->add('startDate', HiddenType::class);
$builder->get('startDate')