<div class="form-group">
    <label for="{{ field.key }}" class="control-label">{{ field.name }}</label>

    {% if field.fieldtype == 'LookupField' or field.fieldtype == 'MultipleLookupField' %}

    <select id="{{ field.key }}" name="{{ field.key }}" class="form-control">
        {% for lookup in field.lookupvalues.all %}
        <option value="{{ lookup.id }}" {% if value == lookup.id %}selected{% endif %}>{{ lookup.name }}</option>
        {% endfor %}
    </select>

    {% else %}

    <input class="form-control {{ classes }}" type="{{ field_type }}" name="{{ field.key }}" id="{{ field.key }}" {% if field.required %}required{% endif %} value="{{ value }}" {% if field.minval %}min="{{ field.minval }}"{% endif %} {% if field.maxval %}max="{{ field.maxval }}"{% endif %} {{ add_on|safe }}>

    {% endif %}
</div>
