Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent empty label divs #450

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
34 changes: 17 additions & 17 deletions templates/forms/layouts/field.html.twig
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{% block field %}
<div class="form-field {{ layout_form_field_outer_classes|trim -}} {{- form_field_outer_core|trim -}}">
{% block contents %}
{% if show_label %}
<div class="{{- layout_form_field_outer_label_classes -}}">
{{- form_field_toggleable -}}
<label class="{{ layout_form_field_label_classes }}{{ form_field_label_trim }}" {% if field.id %}for="{{ form_field_for }}"{% endif %}>
{%- block label -%}
{%- if form_field_help -%}
<span class="tooltip" data-tooltip="{{ form_field_help|e }}">{{ form_field_label|raw }}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was the escaping removed here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like us using |raw without concent from the person who writes the form. Either the property should be called label_html or it should indicate it in some other way, maybe something like

#474 (review)

but with html: true in it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well in this case it is a attribute, so it MUST use escape anyways. It should be added back anyways.

What about this PR itself? Will it be merged?

{%- else -%}
{{ form_field_label|raw }}
{%- endif -%}
{%- if form_field_required %}
<span class="required">*</span>
{%- endif -%}
{%- endblock -%}
</label>
</div>
{% endif %}
{%- block label -%}
{% if show_label %}
<div class="{{- layout_form_field_outer_label_classes -}}">
{{- form_field_toggleable -}}
<label class="{{ layout_form_field_label_classes }}{{ form_field_label_trim }}" {% if field.id %}for="{{ form_field_for }}"{% endif %}>
{%- if form_field_help -%}
<span class="tooltip" data-tooltip="{{ form_field_help }}">{{ form_field_label|raw }}</span>
{%- else -%}
{{ form_field_label|raw }}
{%- endif -%}
{%- if form_field_required %}
<span class="required">*</span>
{%- endif -%}
</label>
</div>
{% endif %}
{%- endblock -%}
<div class="{{ layout_form_field_outer_data_classes }}"
{% block global_attributes %}{% endblock %}
>
Expand Down