{% load form_tags %}

{# Make the field widget type available to templates #}
{% annotate_form_field field %}

<div class="control-group {% for error in field.errors %}error{% endfor %}">
    {% if field.is_hidden %}
        {{ field }}
    {% else %}
		{# Check if field is a checkbox as we mark these up differently #}
		{% if field.widget_type == 'CheckboxInput' %}
			<div class="controls">
    			<label for="{{ field.auto_id }}" class="control-label checkbox {% if field.field.required %}required{% endif %}">{{ field.label }}{% if field.field.required %} <span>*</span>{% endif %}
    				{{ field }}
    			</label>
				{% for error in field.errors %}
					<span class="help-block">{{ error }}</span>
				{% endfor %}
				{% if field.help_text %}
					<span class='help-block'>
						{# We allow HTML within form help fields #}
						{{ field.help_text|safe }}
					</span>
				{% endif %}
			</div>
		{% else %}
			<label for="{{ field.auto_id }}" class="control-label {% if field.field.required %}required{% endif %}">{{ field.label }}{% if field.field.required %} <span>*</span>{% endif %}</label>
			<div class="controls">
				{{ field }}
				{% for error in field.errors %}
					<span class="help-block">{{ error }}</span>
				{% endfor %}
				{% if field.help_text %}
					<span class='help-block'>
						{# We allow HTML within form help fields #}
						{{ field.help_text|safe }}
					</span>
				{% endif %}
			</div>
		{% endif %}
    {% endif %}
</div>
