Skip to content

Commit 86f3e15

Browse files
Merge branch '6.2' into 6.3
* 6.2: fix style of label containing new lines in PUML dump [TwigBridge] Allow floats in html5 input type number field [Translation] Handle the translation of empty strings [VarDumper] Fix error when reflected class has default Enum parameter in constructor [FrameworkBundle] Fix denyAccessUnlessGranted for mixed attributes [Validator] Fix translation of AtLeastOneOf constraint message do not drop embed label classes [Validator] Sync IBAN formats with Swift IBAN registry Update Infobip API transport to use the API V3 [String] Use same alphabet for ByteString::fromRandom tests Fix phpdocs in components Fix the rendering of query explanation with Postgresql
2 parents 0f55d93 + 92379f5 commit 86f3e15

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Extension/Core/Type/NumberType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public function buildView(FormView $view, FormInterface $form, array $options)
4747
{
4848
if ($options['html5']) {
4949
$view->vars['type'] = 'number';
50+
51+
if (!isset($view->vars['attr']['step'])) {
52+
$view->vars['attr']['step'] = 'any';
53+
}
5054
} else {
5155
$view->vars['attr']['inputmode'] = 0 === $options['scale'] ? 'numeric' : 'decimal';
5256
}

Tests/AbstractLayoutTestCase.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,26 @@ public function testRenderNumberWithHtml5NumberType()
18791879
$this->assertWidgetMatchesXpath($form->createView(), [],
18801880
'/input
18811881
[@type="number"]
1882+
[@step="any"]
1883+
[@name="name"]
1884+
[@value="1234.56"]
1885+
'
1886+
);
1887+
}
1888+
1889+
public function testRenderNumberWithHtml5NumberTypeAndStepAttribute()
1890+
{
1891+
$this->requiresFeatureSet(403);
1892+
1893+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56, [
1894+
'html5' => true,
1895+
'attr' => ['step' => '0.1'],
1896+
]);
1897+
1898+
$this->assertWidgetMatchesXpath($form->createView(), [],
1899+
'/input
1900+
[@type="number"]
1901+
[@step="0.1"]
18821902
[@name="name"]
18831903
[@value="1234.56"]
18841904
'

0 commit comments

Comments
 (0)