{%load pgfilters%}
<form class="form-horizontal" method="post" action=".">{%if not nocsrf%}{% csrf_token %}{%endif%}
  {%if form.errors %}
    <div class="alert alert-danger">
      Please correct the errors below, and re-submit the form.
    </div>
  {%endif%}
{%if form.fieldsets%}
{%for fieldset in form.fieldsets%}
<fieldset id="{{fieldset.id}}" class="form-group">
  <legend>{{fieldset.legend}}</legend>
{%if fieldset.description%}<p>{{fieldset.description}}</p>{%endif%}
{%for field in fieldset.fields%}
  {%include "base/form_field.html" with field=form|keylookup:field %}
{%endfor%}
</fieldset>
{%endfor%}
{%else%}
  {% for field in form %}
{%include "base/form_field.html" %}
  {%endfor%}
{%endif%}
  <button type="submit" class="btn btn-primary">{{savebutton|default:"Save"}}</button>
{%if deletebutton%}
  <button type="submit" name="delete" value="delete" class="btn btn-secondary" data-confirm="Are you sure you want to permanently delete this draft?">{{deletebutton}}</button>
{%endif%}
</form>
