{% load widget_tweaks %}
{% load core_tags %}

<div class="form-group{% if field.errors %} has-error{% endif %} field-{{field.html_name}}">

    {% with field|widget_type as type %}

    {% if type != 'checkboxinput' %}
    <label for="{{ field.id_for_label }}" class="control-label">{{ field.label }}</label>
    {% endif%}

    {% if field.help_text %}
    <div class="help-block info">
        {{ field.help_text }}
    </div>
    {% endif %}

    {% if type == 'radioselect' %}

    {% for choice in field %}
    <div class="radio">
        <label>
            {{ choice.tag }}
            {{ choice.choice_label }}
        </label>
    </div>
    {% endfor %}

    {% elif type == 'yesno' %}

    <div class="radio">
    {% for choice in field %}
        <label class="radio-inline">
            {{ choice.tag }}
            {{ choice.choice_label }}
        </label>
    {% endfor %}
    </div>

    {% elif type == 'checkboxinput' %}

    <div class="checkbox">
        <label>
            {{ field }}
            {{ field.label }}
        </label>
    </div>

    {% elif type == 'checkboxselectmultiple' %}

    {% for choice in field %}
    <div class="checkbox">
        <label>
            {{ choice.tag }}
            {{ choice.choice_label }}
        </label>
    </div>
    {% endfor %}

    {% else %}

    {% render_field field class="form-control" %}

    {% endif %}
    {% endwith %}

    {% if field.errors %}
    <div class="help-block error">
        <p class="text-danger">{{ field.errors.as_text}}</p>
    </div>
    {% endif %}
</div>
