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

Commit91e7851

Browse files
committed
render integer types with grouping as text input
1 parent5b1948e commit91e7851

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

‎src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,22 @@ public function testInteger()
18631863
);
18641864
}
18651865

1866+
publicfunctiontestIntegerTypeWithGroupingRendersAsTextInput()
1867+
{
1868+
$form =$this->factory->createNamed('name','Symfony\Component\Form\Extension\Core\Type\IntegerType',123, [
1869+
'grouping' =>true,
1870+
]);
1871+
1872+
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' =>'my&class']],
1873+
'/input
1874+
[@type="text"]
1875+
[@name="name"]
1876+
[@class="my&class form-control"]
1877+
[@value="123"]
1878+
'
1879+
);
1880+
}
1881+
18661882
publicfunctiontestLanguage()
18671883
{
18681884
$form =$this->factory->createNamed('name','Symfony\Component\Form\Extension\Core\Type\LanguageType','de');

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
useSymfony\Component\Form\AbstractType;
1515
useSymfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer;
1616
useSymfony\Component\Form\FormBuilderInterface;
17+
useSymfony\Component\Form\FormInterface;
18+
useSymfony\Component\Form\FormView;
1719
useSymfony\Component\OptionsResolver\OptionsResolver;
1820

1921
class IntegerTypeextends AbstractType
@@ -31,6 +33,16 @@ public function buildForm(FormBuilderInterface $builder, array $options)
3133
));
3234
}
3335

36+
/**
37+
* {@inheritdoc}
38+
*/
39+
publicfunctionbuildView(FormView$view,FormInterface$form,array$options)
40+
{
41+
if ($options['grouping']) {
42+
$view->vars['type'] ='text';
43+
}
44+
}
45+
3446
/**
3547
* {@inheritdoc}
3648
*/

‎src/Symfony/Component/Form/Tests/AbstractLayoutTest.php‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,21 @@ public function testInteger()
17301730
);
17311731
}
17321732

1733+
publicfunctiontestIntegerTypeWithGroupingRendersAsTextInput()
1734+
{
1735+
$form =$this->factory->createNamed('name','Symfony\Component\Form\Extension\Core\Type\IntegerType',123, [
1736+
'grouping' =>true,
1737+
]);
1738+
1739+
$this->assertWidgetMatchesXpath($form->createView(), [],
1740+
'/input
1741+
[@type="text"]
1742+
[@name="name"]
1743+
[@value="123"]
1744+
'
1745+
);
1746+
}
1747+
17331748
publicfunctiontestLanguage()
17341749
{
17351750
$form =$this->factory->createNamed('name','Symfony\Component\Form\Extension\Core\Type\LanguageType','de');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp