Skip to content

Commit c4a6c9f

Browse files
committed
fix not displaying labels when value is false
1 parent a3e6e83 commit c4a6c9f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_base_layout.html.twig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@
6464
{%- if datetime is not defined or not datetime -%}
6565
<div {{ block('widget_container_attributes') -}}>
6666
{%- endif %}
67+
{%- if label is not same as(false) -%}
6768
<div class="sr-only">
6869
{{ form_label(form.year) }}
6970
{{ form_label(form.month) }}
7071
{{ form_label(form.day) }}
7172
</div>
73+
{%- endif -%}
7274

7375
{{- date_pattern|replace({
7476
'{{ year }}': form_widget(form.year),
@@ -89,10 +91,10 @@
8991
{%- if datetime is not defined or false == datetime -%}
9092
<div {{ block('widget_container_attributes') -}}>
9193
{%- endif -%}
92-
<div class="sr-only">{{ form_label(form.hour) }}</div>
94+
{%- if label is not same as(false) -%}<div class="sr-only">{{ form_label(form.hour) }}</div>{%- endif -%}
9395
{{- form_widget(form.hour) -}}
94-
{%- if with_minutes -%}:<div class="sr-only">{{ form_label(form.minute) }}</div>{{ form_widget(form.minute) }}{%- endif -%}
95-
{%- if with_seconds -%}:<div class="sr-only">{{ form_label(form.second) }}</div>{{ form_widget(form.second) }}{%- endif -%}
96+
{%- if with_minutes -%}:{%- if label is not same as(false) -%}<div class="sr-only">{{ form_label(form.minute) }}</div>{%- endif -%}{{ form_widget(form.minute) }}{%- endif -%}
97+
{%- if with_seconds -%}:{%- if label is not same as(false) -%}<div class="sr-only">{{ form_label(form.second) }}</div>{%- endif -%}{{ form_widget(form.second) }}{%- endif -%}
9698
{%- if datetime is not defined or false == datetime -%}
9799
</div>
98100
{%- endif -%}

src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ public function buildForm(FormBuilderInterface $builder, array $options)
133133
'invalid_message_parameters',
134134
)));
135135

136+
if (false === $options['label']) {
137+
$dateOptions['label'] = false;
138+
$timeOptions['label'] = false;
139+
}
140+
136141
if (null !== $options['date_widget']) {
137142
$dateOptions['widget'] = $options['date_widget'];
138143
}

0 commit comments

Comments
 (0)