{% load freeadmin %}
<form data-dojo-type="dijit.form.Form" id="dialogForm_{{ verbose_name }}">
{% block post_form %}
<script type="dojo/event" data-dojo-event="onSubmit" data-dojo-args="e">

var form, iterFunction;
    doSubmit({
       form: this,
       event: e,
       url: '{{ request.path }}'
    });
</script>
{% endblock %}
<table class="form">
    {% csrf_token %}
    {% admin_form form %}
    {% block formset %}
    {% for name, formset in formsets.items %}
    <tr>
        <td colspan="2">
            <table>
                {{ formset.management_form }}
                <tr>
                    <td colspan="2">
                    {{ formset.verbose_name }}
		    <input data-dojo-type="dijit.form.TextBox" type="hidden" name="{{ name }}-__all__" />
                    </td>
                </tr>
                {% for form in formset %}
                <tr>
                    <td colspan="2">
                        <table>
                            {% admin_form form %}
                        </table>
                    </td>
                </tr>
                {% endfor %}

                <tr>
                    <td colspan="2">
                    <a href="javascript:void(0);" onClick="add_formset(this, '{{ model.get_empty_formset_url }}', '{{ formset.prefix|escapejs }}');">{% trans "Add extra" %} {{ formset.verbose_name }}</a>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    {% endfor %}
    {% endblock %}

    <tr><td colspan="2">
	{% if registered %}

        <button id="btn_{{ verbose_name}}_Add" class="submitform" data-dojo-type="dijit.form.Button" data-dojo-props="type: 'submit'">
            <script type="dojo/method">
                {{ extra_js }}
            </script>
            {% trans "Submit" %}
        </button>
        <button id="btn_{{ verbose_name}}_Cancel" data-dojo-type="dijit.form.Button" class="cancelform">
            {% trans "Reset" %}
            <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="evt">
                form = getForm(this);
                form.reset();
            </script>
        </button>
        {% with form.advanced_fields as advfields %}
        {% include "freeadmin/advanced_btn.html" %}
        {% endwith %}
        {% block buttons_extra %}
        {% endblock %}

	{% else %}

	<div>
	<span style="color:red;font-weight:bold;">
	<pre>
		You must be registered to submit a request for support.
		Please register under Settings->Registration.
	</pre>
	</span>
	</div>

	{% endif %}

    </td></tr>
</table>
</form>
