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

Appearance settings

Commit 91e7851

Browse filesBrowse files
committed
render integer types with grouping as text input
1 parent 5b1948e commit 91e7851
Copy full SHA for 91e7851

File tree

3 files changed

+43
-0
lines changed
Filter options

3 files changed

+43
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,22 @@ public function testInteger()
18631863
);
18641864
}
18651865

1866+
public function testIntegerTypeWithGroupingRendersAsTextInput()
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
public function testLanguage()
18671883
{
18681884
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LanguageType', 'de');

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/IntegerType.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Symfony\Component\Form\AbstractType;
1515
use Symfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer;
1616
use Symfony\Component\Form\FormBuilderInterface;
17+
use Symfony\Component\Form\FormInterface;
18+
use Symfony\Component\Form\FormView;
1719
use Symfony\Component\OptionsResolver\OptionsResolver;
1820

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

36+
/**
37+
* {@inheritdoc}
38+
*/
39+
public function buildView(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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,21 @@ public function testInteger()
17301730
);
17311731
}
17321732

1733+
public function testIntegerTypeWithGroupingRendersAsTextInput()
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
public function testLanguage()
17341749
{
17351750
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LanguageType', 'de');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.