From c4a6c9fa00b4f39b12066782c3943c690ffc1733 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 14 Sep 2018 15:32:30 +0200 Subject: [PATCH] fix not displaying labels when value is false --- .../Resources/views/Form/bootstrap_base_layout.html.twig | 8 +++++--- .../Component/Form/Extension/Core/Type/DateTimeType.php | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_base_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_base_layout.html.twig index 2630803573..136cabccb1 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_base_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_base_layout.html.twig @@ -64,11 +64,13 @@ {%- if datetime is not defined or not datetime -%}
{%- endif %} + {%- if label is not same as(false) -%}
{{ form_label(form.year) }} {{ form_label(form.month) }} {{ form_label(form.day) }}
+ {%- endif -%} {{- date_pattern|replace({ '{{ year }}': form_widget(form.year), @@ -89,10 +91,10 @@ {%- if datetime is not defined or false == datetime -%}
{%- endif -%} -
{{ form_label(form.hour) }}
+ {%- if label is not same as(false) -%}
{{ form_label(form.hour) }}
{%- endif -%} {{- form_widget(form.hour) -}} - {%- if with_minutes -%}:
{{ form_label(form.minute) }}
{{ form_widget(form.minute) }}{%- endif -%} - {%- if with_seconds -%}:
{{ form_label(form.second) }}
{{ form_widget(form.second) }}{%- endif -%} + {%- if with_minutes -%}:{%- if label is not same as(false) -%}
{{ form_label(form.minute) }}
{%- endif -%}{{ form_widget(form.minute) }}{%- endif -%} + {%- if with_seconds -%}:{%- if label is not same as(false) -%}
{{ form_label(form.second) }}
{%- endif -%}{{ form_widget(form.second) }}{%- endif -%} {%- if datetime is not defined or false == datetime -%}
{%- endif -%} diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php index 505b42b42e..4c824ad36b 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php @@ -133,6 +133,11 @@ class DateTimeType extends AbstractType 'invalid_message_parameters', ))); + if (false === $options['label']) { + $dateOptions['label'] = false; + $timeOptions['label'] = false; + } + if (null !== $options['date_widget']) { $dateOptions['widget'] = $options['date_widget']; }