{% load libs_tags %}
{% get_form_field_type field as field_type %}
{% if placeholder %}
    {% add_form_widget_attr field 'placeholder' placeholder replace=1 as field %}
{% endif %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
    {% if not hide_label and "CheckboxInput" not in field_type %}
        <label class="control-label {% if horizontal %}col-sm-4{% endif %}" for="{{ field.id_for_label }}">
            <span {% if field.field.required %}class="required-label"{% endif %}>{% if field.field.required %}* {% endif %}{{ field.label }}</span>
            {% if field.help_text %}
                <span data-class="popover" class="glyphicon glyphicon-question-sign" title="{{ field.label }}" data-content="{{ field.help_text }}"></span>
            {% endif %}
        </label>
    {% elif horizontal and "CheckboxInput" in field_type %}
	<label class="control-label col-sm-4"></label>
    {% endif %}
    {% if horizontal %}<div class="col-sm-8">{% endif %}
    {% if "CheckboxInput" in field_type %}
        <div class="checkbox">
            <label>
                {{ field }}
                <span {% if field.field.required %}class="required-label"{% endif %}>{% if field.field.required %}* {% endif %}{{ field.label }}</span>
                {% if field.help_text %}
                    <span data-class="popover" class="glyphicon glyphicon-question-sign" title="{{ field.label }}" data-content="{{ field.help_text }}"></span>
                {% endif %}
            </label>
        </div>
    {% else %}
        {% add_form_widget_attr field 'class' 'form-control' as field %}
        {{ field }}
    {% endif %}
    {% if field.errors %}
        <span class="help-block">{% for error in field.errors %}{{ error }}<br/> {% endfor %}</span>
    {% endif %}
    {% if horizontal %}</div>{% endif %}
</div>
