{% load smartmin %}

{% with form|field:field as form_field %}
{% getblock "before_field_" field %}

{% if form_field and form_field.is_hidden %}
{{ form_field }}
{% else %}
{% if form_field != None %}
<div class="form-group {% if form_field.errors %}error{% endif %}">
  <label class="col-sm-2 control-label" for="{{ field.name }}">{% get_label field %}</label>
  <div class="col-sm-10 smartmin-form-field">
    {{ form_field|add_css:"form-control" }}
    {% with view|field_help:field as help %}
    {% if help %}
    <span class="help-block">{{ help }}</span>
    {% endif %}
    {% endwith %}

    {% if form_field.errors %}
    <span class="help-block field-errors">{{ form_field.errors }}</span>
    {% endif %}
 </div>
</div>
{% else %}
<div class="form-group">
  <label class="col-sm-2 control-label" for="{{ field.name }}">{% get_label field %}</label>
  <div class="col-sm-10">
    <span class="form-control uneditable-input">{% get_value_from_view field %}</span>
    {% with view|field_help:field as help %}
    {% if help %}
    <span class="help-block">{{ help }}</span>
    {% endif %}
    {% endwith %}
  </div>
</div>
{% endif %}
{% endif %}

{% getblock "after_field_" field %}

{% endwith %}
