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

Commit22f3851

Browse files
committed
[Form] Fixed trimming choice values
1 parent1067468 commit22f3851

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ public function configureOptions(OptionsResolver $resolver)
413413
// See https://github.com/symfony/symfony/pull/5582
414414
'data_class' =>null,
415415
'choice_translation_domain' =>true,
416+
'trim' =>false,
416417
));
417418

418419
$resolver->setNormalizer('choices',$choicesNormalizer);

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,4 +2421,37 @@ public function invalidNestedValueTestMatrix()
24212421
'multiple, expanded' =>array(true,true,array(array())),
24222422
);
24232423
}
2424+
2425+
/**
2426+
* @dataProvider provideTrimCases
2427+
*/
2428+
publicfunctiontestTrimIsDisabled($multiple,$expanded)
2429+
{
2430+
$form =$this->factory->create(static::TESTED_TYPE,null,array(
2431+
'multiple' =>$multiple,
2432+
'expanded' =>$expanded,
2433+
'choices' =>array(
2434+
'a' =>'1',
2435+
),
2436+
'choices_as_values' =>true,
2437+
));
2438+
2439+
$submittedData =' 1';
2440+
2441+
$form->submit($multiple ? (array)$submittedData :$submittedData);
2442+
2443+
// When the choice does not exist the transformation fails
2444+
$this->assertFalse($form->isSynchronized());
2445+
$this->assertNull($form->getData());
2446+
}
2447+
2448+
publicfunctionprovideTrimCases()
2449+
{
2450+
returnarray(
2451+
'Simple' =>array(false,false),
2452+
'Multiple' =>array(true,false),
2453+
'Simple expanded' =>array(false,true),
2454+
'Multiple expanded' =>array(true,true),
2455+
);
2456+
}
24242457
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp