Skip to content

Commit

Permalink
fix(admin/field): deep recompute time field type (#1094)
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 authored Dec 5, 2024
1 parent 2db671b commit 092d3c0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions EMS/core-bundle/src/Form/DataField/TimeFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ public function reverseViewTransform($data, FieldType $fieldType): DataField
{
$format = static::getFormat($fieldType->getOptions());
$converted = !\is_array($data) ? \DateTime::createFromFormat($format, \strval($data)) : false;
$convertedFromStoreFormat = !\is_array($data) ? \DateTime::createFromFormat($this::STOREFORMAT, \strval($data)) : false;
if ($converted) {
$out = $converted->format($this::STOREFORMAT);
} elseif ($convertedFromStoreFormat) {
$out = $convertedFromStoreFormat->format($this::STOREFORMAT);
} else {
$out = null;
}
Expand Down

0 comments on commit 092d3c0

Please sign in to comment.