mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +00:00
adding location hidden field in Calendar formType
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Chill\CalendarBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
@@ -155,7 +156,7 @@ class CalendarType extends AbstractType
|
||||
}
|
||||
))
|
||||
;
|
||||
|
||||
|
||||
$builder->add('calendarRange', HiddenType::class);
|
||||
$builder->get('calendarRange')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
@@ -178,6 +179,20 @@ class CalendarType extends AbstractType
|
||||
))
|
||||
;
|
||||
|
||||
$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]);
|
||||
}
|
||||
))
|
||||
;
|
||||
|
||||
// $builder->add('invites', HiddenType::class);
|
||||
// $builder->get('invites')
|
||||
|
Reference in New Issue
Block a user