Skip to content

Commit 92379f5

Browse files
Merge branch '5.4' into 6.2
* 5.4: 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 [Validator] Sync IBAN formats with Swift IBAN registry [String] Use same alphabet for ByteString::fromRandom tests Fix phpdocs in components
2 parents f491e48 + 39b8a9e commit 92379f5

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
@@ -41,6 +41,10 @@ public function buildView(FormView $view, FormInterface $form, array $options)
4141
{
4242
if ($options['html5']) {
4343
$view->vars['type'] = 'number';
44+
45+
if (!isset($view->vars['attr']['step'])) {
46+
$view->vars['attr']['step'] = 'any';
47+
}
4448
} else {
4549
$view->vars['attr']['inputmode'] = 0 === $options['scale'] ? 'numeric' : 'decimal';
4650
}

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)