Skip to content

Commit f1899fd

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 d2d50dc + bd1cad2 commit f1899fd

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

Extension/TranslationExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ public function trans(string|\Stringable|TranslatableInterface|null $message, ar
103103
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be a locale passed as a string when the message is a "%s", "%s" given.', __METHOD__, TranslatableInterface::class, get_debug_type($arguments)));
104104
}
105105

106+
if ($message instanceof TranslatableMessage && '' === $message->getMessage()) {
107+
return '';
108+
}
109+
106110
return $message->trans($this->getTranslator(), $locale ?? (\is_string($arguments) ? $arguments : null));
107111
}
108112

Tests/Extension/AbstractBootstrap3LayoutTestCase.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,25 @@ public function testRenderNumberWithHtml5NumberType()
21542154
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
21552155
'/input
21562156
[@type="number"]
2157+
[@step="any"]
2158+
[@name="name"]
2159+
[@class="my&class form-control"]
2160+
[@value="1234.56"]
2161+
'
2162+
);
2163+
}
2164+
2165+
public function testRenderNumberWithHtml5NumberTypeAndStepAttribute()
2166+
{
2167+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56, [
2168+
'html5' => true,
2169+
'attr' => ['step' => '0.1'],
2170+
]);
2171+
2172+
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
2173+
'/input
2174+
[@type="number"]
2175+
[@step="0.1"]
21572176
[@name="name"]
21582177
[@class="my&class form-control"]
21592178
[@value="1234.56"]

Tests/Extension/TranslationExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public static function getTransTests()
124124
['{{ foo|trans }}', '', ['foo' => null]],
125125

126126
// trans object
127+
['{{ t("")|trans }}', ''],
127128
['{{ t("Hello")|trans }}', 'Hello'],
128129
['{{ t(name)|trans }}', 'Symfony', ['name' => 'Symfony']],
129130
['{{ t(hello, { \'%name%\': \'Symfony\' })|trans }}', 'Hello Symfony', ['hello' => 'Hello %name%']],

0 commit comments

Comments
 (0)