bug #28469 [Form][TwigBridge] fix not displaying labels when value is false (xabbuh)
This PR was merged into the 4.1 branch.
Discussion
----------
[Form][TwigBridge] fix not displaying labels when value is false
| Q | A
| ------------- | ---
| Branch? | 4.1
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #28198
| License | MIT
| Doc PR |
Commits
-------
c4a6c9fa00
fix not displaying labels when value is false
This commit is contained in:
commit
1f98703e14
@ -64,11 +64,13 @@
|
|||||||
{%- if datetime is not defined or not datetime -%}
|
{%- if datetime is not defined or not datetime -%}
|
||||||
<div {{ block('widget_container_attributes') -}}>
|
<div {{ block('widget_container_attributes') -}}>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
{%- if label is not same as(false) -%}
|
||||||
<div class="sr-only">
|
<div class="sr-only">
|
||||||
{{ form_label(form.year) }}
|
{{ form_label(form.year) }}
|
||||||
{{ form_label(form.month) }}
|
{{ form_label(form.month) }}
|
||||||
{{ form_label(form.day) }}
|
{{ form_label(form.day) }}
|
||||||
</div>
|
</div>
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
{{- date_pattern|replace({
|
{{- date_pattern|replace({
|
||||||
'{{ year }}': form_widget(form.year),
|
'{{ year }}': form_widget(form.year),
|
||||||
@ -89,10 +91,10 @@
|
|||||||
{%- if datetime is not defined or false == datetime -%}
|
{%- if datetime is not defined or false == datetime -%}
|
||||||
<div {{ block('widget_container_attributes') -}}>
|
<div {{ block('widget_container_attributes') -}}>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
<div class="sr-only">{{ form_label(form.hour) }}</div>
|
{%- if label is not same as(false) -%}<div class="sr-only">{{ form_label(form.hour) }}</div>{%- endif -%}
|
||||||
{{- form_widget(form.hour) -}}
|
{{- form_widget(form.hour) -}}
|
||||||
{%- if with_minutes -%}:<div class="sr-only">{{ form_label(form.minute) }}</div>{{ form_widget(form.minute) }}{%- endif -%}
|
{%- 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 -%}
|
||||||
{%- if with_seconds -%}:<div class="sr-only">{{ form_label(form.second) }}</div>{{ form_widget(form.second) }}{%- endif -%}
|
{%- 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 -%}
|
||||||
{%- if datetime is not defined or false == datetime -%}
|
{%- if datetime is not defined or false == datetime -%}
|
||||||
</div>
|
</div>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
@ -120,6 +120,11 @@ class DateTimeType extends AbstractType
|
|||||||
'invalid_message_parameters',
|
'invalid_message_parameters',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
if (false === $options['label']) {
|
||||||
|
$dateOptions['label'] = false;
|
||||||
|
$timeOptions['label'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (null !== $options['date_widget']) {
|
if (null !== $options['date_widget']) {
|
||||||
$dateOptions['widget'] = $options['date_widget'];
|
$dateOptions['widget'] = $options['date_widget'];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user