Skip to content

Instantly share code, notes, and snippets.

@perk11
Created October 23, 2015 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perk11/a63e15f38f8aeb8381f3 to your computer and use it in GitHub Desktop.
Save perk11/a63e15f38f8aeb8381f3 to your computer and use it in GitHub Desktop.
{% block checkbox_radio_label %}
{# Do not display the label if widget is not defined in order to prevent double label rendering #}
{% if widget is defined %}
{% if required %}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %}
{% endif %}
{% if parent_label_class is defined %}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) %}
{% endif %}
{% if label is not sameas(false) and label is empty %}
{% set label = name|humanize %}
{% endif %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{- widget|raw -}}
{{- label is not sameas(false) ? label|trans({}, translation_domain) -}}
</label>
{% endif %}
{% endblock checkbox_radio_label %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment