Skip to content

Commit 69f600d

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 815e39f + f1899fd commit 69f600d

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-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

Resources/views/Form/bootstrap_4_layout.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@
261261
{%- if required -%}
262262
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%}
263263
{%- endif -%}
264+
{%- if parent_label_class is defined -%}
265+
{% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %}
266+
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%}
267+
{% endif %}
264268

265269
{{ widget|raw }}
266270
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>

Tests/Extension/AbstractBootstrap3LayoutTestCase.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,25 @@ public function testRenderNumberWithHtml5NumberType()
21502150
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
21512151
'/input
21522152
[@type="number"]
2153+
[@step="any"]
2154+
[@name="name"]
2155+
[@class="my&class form-control"]
2156+
[@value="1234.56"]
2157+
'
2158+
);
2159+
}
2160+
2161+
public function testRenderNumberWithHtml5NumberTypeAndStepAttribute()
2162+
{
2163+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56, [
2164+
'html5' => true,
2165+
'attr' => ['step' => '0.1'],
2166+
]);
2167+
2168+
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
2169+
'/input
2170+
[@type="number"]
2171+
[@step="0.1"]
21532172
[@name="name"]
21542173
[@class="my&class form-control"]
21552174
[@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)