mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 14:36:13 +00:00
Fix travelTime field
This commit is contained in:
parent
4fd13440c6
commit
f836114d84
@ -219,15 +219,17 @@ class ActivityType extends AbstractType
|
||||
]);
|
||||
}
|
||||
|
||||
$builder->get('durationTime')
|
||||
foreach (['durationTime', 'travelTime'] as $fieldName) {
|
||||
$builder->get($fieldName)
|
||||
->addModelTransformer($durationTimeTransformer);
|
||||
|
||||
$builder->get('durationTime')
|
||||
$builder->get($fieldName)
|
||||
->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $formEvent) use (
|
||||
$timeChoices,
|
||||
$builder,
|
||||
$durationTimeTransformer,
|
||||
$durationTimeOptions
|
||||
$durationTimeOptions,
|
||||
$fieldName
|
||||
) {
|
||||
// set the timezone to GMT, and fix the difference between current and GMT
|
||||
// the datetimetransformer will then handle timezone as GMT
|
||||
@ -245,9 +247,8 @@ class ActivityType extends AbstractType
|
||||
if (!in_array($data->getTimestamp(), $timeChoices)) {
|
||||
// the data are not in the possible values. add them
|
||||
$timeChoices[$data->format('H:i')] = $data->getTimestamp();
|
||||
$form = $builder->create('durationTime', ChoiceType::class, array_merge(
|
||||
$durationTimeOptions,
|
||||
[
|
||||
$form = $builder->create($fieldName, ChoiceType::class, array_merge(
|
||||
$durationTimeOptions, [
|
||||
'choices' => $timeChoices,
|
||||
'auto_initialize' => false
|
||||
]
|
||||
@ -257,6 +258,9 @@ class ActivityType extends AbstractType
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user