{% load i18n %}
{% load bootstrap3 %}
{% load escapejson %}
{% load formset_tags %}
<div class="formset" data-formset data-formset-prefix="{{ formset.prefix }}">
    {{ formset.management_form }}
    {% bootstrap_formset_errors formset %}
    <div data-formset-body>
        {% for f in formset %}
            {% bootstrap_form_errors f %}
            <div class="row formset-row" data-formset-form>
                <div class="sr-only">
                    {{ f.id }}
                    {% bootstrap_field f.DELETE form_group_class="" layout="inline" %}
                    {% bootstrap_field f.ORDER form_group_class="" layout="inline" %}
                </div>
                <div class="col-md-4">
                    {% bootstrap_field f.pretix_field layout='inline' form_group_class="" %}
                </div>
                <div class="col-md-4">
                    {% bootstrap_field f.external_field layout='inline' form_group_class="" %}
                </div>
                <div class="col-md-2">
                    {% bootstrap_field f.overwrite layout='inline' form_group_class="" %}
                </div>
                {{ f.value_map.as_hidden }}
                <div class="col-md-2 text-right flip">
                    <i class="fa fa-warning hidden" data-toggle="tooltip" title=""></i>

                    <button type="button" class="btn btn-default hidden" data-edit-value-map data-toggle="modal"
                            data-target="#editValueMapModal" title="{% trans "Edit value mapping" %}">
                        <i class="fa fa-edit"></i></button>
                    <button type="button" class="btn btn-default" data-formset-move-up-button>
                        <i class="fa fa-arrow-up"></i></button>
                    <button type="button" class="btn btn-default" data-formset-move-down-button>
                        <i class="fa fa-arrow-down"></i></button>
                    <button type="button" class="btn btn-danger" data-formset-delete-button>
                        <i class="fa fa-trash"></i></button>
                </div>
            </div>
        {% endfor %}
    </div>
    <script type="form-template" data-formset-empty-form>
        {% escapescript %}
            <div class="row formset-row" data-formset-form>
                <div class="sr-only">
                    {% bootstrap_field formset.empty_form.DELETE form_group_class="" layout="inline" %}
                </div>
                <div class="col-md-4">
                    {% bootstrap_field formset.empty_form.pretix_field layout='inline' form_group_class="" %}
                </div>
                <div class="col-md-4">
                    {% bootstrap_field formset.empty_form.external_field layout='inline' form_group_class="" %}
                </div>
                <div class="col-md-2">
                    {% bootstrap_field formset.empty_form.overwrite layout='inline' form_group_class="" %}
                </div>
                {{ formset.empty_form.value_map.as_hidden }}
                <div class="col-md-2 text-right flip">
                    <i class="fa fa-warning hidden" data-toggle="tooltip" title=""></i>
                    <button type="button" class="btn btn-default hidden" data-edit-value-map data-toggle="modal"
                            data-target="#editValueMapModal" title="{% trans "Edit value mapping" %}">
                        <i class="fa fa-edit"></i></button>
                    <button type="button" class="btn btn-default" data-formset-move-up-button>
                        <i class="fa fa-arrow-up"></i></button>
                    <button type="button" class="btn btn-default" data-formset-move-down-button>
                        <i class="fa fa-arrow-down"></i></button>
                    <button type="button" class="btn btn-danger" data-formset-delete-button>
                        <i class="fa fa-trash"></i></button>
                </div>
            </div>
        {% endescapescript %}
    </script>
    <p>
        <button type="button" class="btn btn-default" data-formset-add>
            <i class="fa fa-plus"></i> {% trans "Add property" %}</button>
    </p>
</div>
{% if external_fields %}
    {{ external_fields|json_script:external_fields_id }}
{% endif %}
