{% load i18n %}
{% load wger_extras %}
{% if not field.is_hidden %}
<div class="form-group {% if field.errors %}has-error{% endif %}" id="form-{{field.name}}">
    <div {% if field.errors %}class="has-error has-feedback"{% endif %}>

        <label for="{{field.auto_id}}" class="col-md-3 control-label">
            {% trans field.label %}
            {% if not field.field.required %}
                <br>
                <span style="font-size:90%;">— <em>{% trans "Optional" %}</em></span>
            {% endif %}
        </label>

        <div class="col-md-9">
            {% if not field|is_checkbox and not field|is_fileupload %}
                {{ field|form_field_add_css:'form-control' }}
            {% elif field|is_checkbox %}
                {{ field|form_field_add_css:'checkbox' }}
            {% else %}
                {{ field }}
            {% endif %}

            {% if field.errors %}
                <span class="glyphicon glyphicon-remove form-control-feedback"></span>
            {% endif %}

            <span class="help-block">
            {% for error in field.errors %}
                <p>{% trans error %}</p>
            {% endfor %}

            {% if field.help_text %}{% trans field.help_text %}{% endif %}
            </span>
        </div>

    </div>
</div>
{% else %}
    {{field}}
{% endif %}