mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-28 13:06:13 +00:00
fix behaviour of CalendarType in Controller and add field users to CalendarType
This commit is contained in:
parent
67fad5d764
commit
2b770036a5
@ -295,9 +295,8 @@ class CalendarController extends AbstractController
|
||||
$entity->setAccompanyingPeriod($accompanyingPeriod);
|
||||
}
|
||||
|
||||
$form = $this->createForm(CalendarType::class, $entity, [
|
||||
'accompanyingPeriod' => $accompanyingPeriod,
|
||||
])->handleRequest($request);
|
||||
$form = $this->createForm(CalendarType::class, $entity);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em->persist($entity);
|
||||
|
@ -129,6 +129,10 @@ class CalendarType extends AbstractType
|
||||
->addModelTransformer($this->partiesToIdDataTransformer);
|
||||
*/
|
||||
|
||||
$builder->add('users', HiddenType::class);
|
||||
$builder->get('users')
|
||||
->addModelTransformer($this->idToUsersDataTransformer);
|
||||
|
||||
$builder->add('calendarRange', HiddenType::class);
|
||||
$builder->get('calendarRange')
|
||||
->addModelTransformer($this->calendarRangeDataTransformer);
|
||||
|
@ -1,10 +1,6 @@
|
||||
---
|
||||
services:
|
||||
chill.calendar.form.type.calendar:
|
||||
class: Chill\CalendarBundle\Form\CalendarType
|
||||
arguments:
|
||||
- "@chill.main.helper.translatable_string"
|
||||
- "@doctrine.orm.entity_manager"
|
||||
|
||||
tags:
|
||||
- { name: form.type, alias: chill_calendarbundle_calendar }
|
||||
services:
|
||||
Chill\CalendarBundle\Form\:
|
||||
resource: './../../Form'
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
@ -107,6 +107,8 @@ final class CalendarTypeTest extends TypeTestCase
|
||||
$this->assertEquals(8, $calendar->getCalendarRange()->getId());
|
||||
$this->assertEquals(9, $calendar->getLocation()->getId());
|
||||
$this->assertEquals(true, $calendar->getSendSMS());
|
||||
$this->assertContains(2, $calendar->getUsers()->map(function (User $u) { return $u->getId(); }));
|
||||
$this->assertContains(3, $calendar->getUsers()->map(function (User $u) { return $u->getId(); }));
|
||||
}
|
||||
|
||||
protected function getExtensions()
|
||||
|
@ -88,6 +88,10 @@ class IdToEntityDataTransformer implements DataTransformerInterface
|
||||
return implode(',', $ids);
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$id = call_user_func($this->getId, $value);
|
||||
|
||||
if (null === $id) {
|
||||
|
@ -143,3 +143,7 @@ services:
|
||||
Chill\MainBundle\Form\Type\LocationFormType: ~
|
||||
|
||||
Chill\MainBundle\Form\WorkflowStepType: ~
|
||||
|
||||
Chill\MainBundle\Form\DataTransformer\IdToLocationDataTransformer: ~
|
||||
Chill\MainBundle\Form\DataTransformer\IdToUserDataTransformer: ~
|
||||
Chill\MainBundle\Form\DataTransformer\IdToUsersDataTransformer: ~
|
||||
|
Loading…
x
Reference in New Issue
Block a user