Skip to content

Commit 02bd42a

Browse files
Merge branch '7.4' into 8.0
* 7.4: [TypeInfo] Simple array should be array type Handle signals on text input [TwigBridge] Fix form constraint [Runtime] Reuse the already created Request object when the app needs it as argument returns a kernel [Config] Fix array shape generation for backed enums [Config] Define `TreeBuilder` default generic type Update validators.el.xlf Fix MoneyType: add missing step attribute when html5=true [JsonStreamer] fix invalid json output for list of self [Console] Preserve `--help` option when a command is not found [FrameworkBundle] Fix using `FailedMessages*Command` with `SigningSerializer` [Lock] Fix unserializing already serialized Key payloads [HttpClient] CachingHttpClient must run after UriTemplate and Scoping Only register PhpConfigReferenceDumpPass in dev env with debug flag enabled [Messenger] Fix PHP 8.5 deprecation for pgsqlGetNotify() in PostgreSQL transport chore: PHP CS Fixer - do not use deprecated sets in config verify spanish translations with state needs-review-translation [Security] Fix OIDC discovery when using multiple HttpClient instances [DependencyInjection] Allow manual bindings on parameters with #[Target]
2 parents e250408 + 04984c7 commit 02bd42a

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Extension/Core/Type/MoneyType.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public function buildView(FormView $view, FormInterface $form, array $options):
5151

5252
if ($options['html5']) {
5353
$view->vars['type'] = 'number';
54+
55+
if (!isset($view->vars['attr']['step'])) {
56+
$view->vars['attr']['step'] = 'any';
57+
}
58+
} else {
59+
$view->vars['attr']['inputmode'] = 0 === $options['scale'] ? 'numeric' : 'decimal';
5460
}
5561
}
5662

Tests/Extension/Core/Type/MoneyTypeTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,46 @@ public function testHtml5EnablesSpecificFormatting()
126126
$this->assertSame('number', $form->createView()->vars['type']);
127127
}
128128

129+
public function testHtml5AddsStepAttributeIfNotSet()
130+
{
131+
$form = $this->factory->create(static::TESTED_TYPE, null, [
132+
'html5' => true,
133+
]);
134+
$view = $form->createView();
135+
$this->assertSame('any', $view->vars['attr']['step']);
136+
137+
$form = $this->factory->create(static::TESTED_TYPE, null, [
138+
'html5' => false,
139+
'scale' => 2,
140+
]);
141+
$view = $form->createView();
142+
$this->assertSame('decimal', $view->vars['attr']['inputmode']);
143+
144+
$form = $this->factory->create(static::TESTED_TYPE, null, [
145+
'html5' => false,
146+
'scale' => 0,
147+
]);
148+
$view = $form->createView();
149+
$this->assertSame('numeric', $view->vars['attr']['inputmode']);
150+
}
151+
152+
public function testHtml5DoesNotOverrideUserProvidedStep()
153+
{
154+
$form = $this->factory->create(static::TESTED_TYPE, null, [
155+
'html5' => true,
156+
'attr' => ['step' => '0.01'],
157+
]);
158+
$view = $form->createView();
159+
$this->assertSame('0.01', $view->vars['attr']['step']);
160+
161+
$form = $this->factory->create(static::TESTED_TYPE, null, [
162+
'html5' => false,
163+
'scale' => 2,
164+
]);
165+
$view = $form->createView();
166+
$this->assertSame('decimal', $view->vars['attr']['inputmode']);
167+
}
168+
129169
public function testDefaultInput()
130170
{
131171
$form = $this->factory->create(static::TESTED_TYPE, null, ['divisor' => 100]);

0 commit comments

Comments
 (0)