{% load i18n l10n tbxforms %}

<fieldset
    class="tbxforms-fieldset"
    {% if field.help_text or field.errors %}
        aria-describedby="{% for error in field.errors %}{{ field.auto_id }}_{{ forloop.counter }}_error {% endfor %}{% if field.help_text %}{{ field.auto_id }}_hint{% endif %}"
    {% endif %}
>

    {% if field.label %}
        <legend class="tbxforms-fieldset__legend{% if legend_size %} {{ legend_size }}{% endif %}">
            {% if legend_tag %}<{{ legend_tag }} class="tbxforms-fieldset__heading">{% endif %}
            {{ field.label|safe }}
            {% if not field|show_as_required %} <span>{% trans "(optional)" %}</span>{% endif %}
            {% if legend_tag %}</{{ legend_tag }}>{% endif %}
        </legend>
    {% endif %}

    {% include 'tbx/layout/help_text_and_errors.html' %}
    {% crispy_tbx_field field %}

</fieldset>
