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 f331c54

Browse filesBrowse files
bug #30061 [Form] render integer types with grouping as text input (xabbuh)
This PR was merged into the 3.4 branch. Discussion ---------- [Form] render integer types with grouping as text input | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29422 | License | MIT | Doc PR | Commits ------- d6a5fde render integer types with grouping as text input
2 parents eb2a18e + d6a5fde commit f331c54
Copy full SHA for f331c54

File tree

4 files changed

+44
-1
lines changed
Filter options

4 files changed

+44
-1
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/Bridge/Twig/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"symfony/asset": "~2.8|~3.0|~4.0",
2424
"symfony/dependency-injection": "~2.8|~3.0|~4.0",
2525
"symfony/finder": "~2.8|~3.0|~4.0",
26-
"symfony/form": "^3.4.22|~4.1.11|^4.2.3",
26+
"symfony/form": "^3.4.23|^4.2.4",
2727
"symfony/http-foundation": "^3.3.11|~4.0",
2828
"symfony/http-kernel": "~3.2|~4.0",
2929
"symfony/polyfill-intl-icu": "~1.0",

‎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.