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