rdv: add the concernedGroup vuejs component in add a new rdv

This commit is contained in:
nobohan
2021-07-16 18:21:27 +02:00
parent 20d113b1db
commit 1557b8f80a
7 changed files with 272 additions and 0 deletions

View File

@@ -13,6 +13,9 @@ use Chill\MainBundle\Form\Type\CommentType;
use Chill\CalendarBundle\Entity\Calendar;
use Chill\CalendarBundle\Entity\CancelReason;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
class CalendarType extends AbstractType
{
@@ -60,6 +63,26 @@ class CalendarType extends AbstractType
))
;
$builder->add('persons', HiddenType::class);
$builder->get('persons')
->addModelTransformer(new CallbackTransformer(
function (iterable $personsAsIterable): string {
$personIds = [];
foreach ($personsAsIterable as $value) {
$personIds[] = $value->getId();
}
return implode(',', $personIds);
},
function (?string $personsAsString): array {
return array_map(
fn(string $id): ?Person => $this->om->getRepository(Person::class)->findOneBy(['id' => (int) $id]),
explode(',', $personsAsString)
);
}
))
;
}/**
* {@inheritdoc}
*/