Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf9b731e

Browse files
KDederichsxabbuh
authored andcommitted
Use reference date in reverse transform
Fixes#40997
1 parent76f6d74 commitf9b731e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

‎src/Symfony/Component/Form/Extension/Core/Type/TimeType.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
204204
));
205205
}elseif ('array' ===$options['input']) {
206206
$builder->addModelTransformer(newReversedTransformer(
207-
newDateTimeToArrayTransformer($options['model_timezone'],$options['model_timezone'],$parts)
207+
newDateTimeToArrayTransformer($options['model_timezone'],$options['model_timezone'],$parts,'text' ===$options['widget'],$options['reference_date'])
208208
));
209209
}
210210
}

‎src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,27 @@ public function testArrayTimeWithReferenceDoesNotUseReferenceTimeOnZero()
991991
$this->assertSame($input,$form->getViewData());
992992
}
993993

994+
publicfunctiontestArrayTimeWithReferenceDoesUseReferenceDateOnModelTransform()
995+
{
996+
$input = [
997+
'hour' =>'21',
998+
'minute' =>'45',
999+
];
1000+
1001+
$form =$this->factory->create(static::TESTED_TYPE,$input, [
1002+
'model_timezone' =>'UTC',
1003+
'view_timezone' =>'Europe/Berlin',
1004+
'reference_date' =>new \DateTimeImmutable('01-05-2021 12:34:56',new \DateTimeZone('UTC')),
1005+
'input' =>'array',
1006+
]);
1007+
1008+
$this->assertSame($input,$form->getData());
1009+
$this->assertEquals([
1010+
'hour' =>'23',
1011+
'minute' =>'45',
1012+
],$form->getViewData());
1013+
}
1014+
9941015
/**
9951016
* @dataProvider provideEmptyData
9961017
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp