summaryrefslogtreecommitdiffstats
path: root/templates/w3/table_inline_formset.html
blob: a4b951d24f0ad33a4a94a9c9b124fd7d8002738e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{% load crispy_forms_tags %}
{% load crispy_forms_utils %}
{% load crispy_forms_field %}

{% specialspaceless %}
{% if formset_tag %}
<form {{ flat_attrs }} method="{{ form_method }}" {% if formset.is_multipart %} enctype="multipart/form-data"{% endif %}>
{% endif %}
    {% if formset_method|lower == 'post' and not disable_csrf %}
        {% csrf_token %}
    {% endif %}

    <div>
        {{ formset.management_form|crispy }}
    </div>

    <table{% if form_id %} id="{{ form_id }}_table"{% endif%} class="table table-striped table-sm">
        <thead>
            {% if formset.readonly and not formset.queryset.exists %}
            {% else %}
                <tr>
                    {% for field in formset.forms.0 %}
                        {% if field.label and not field.is_hidden %}
                            <th for="{{ field.auto_id }}" class="col-form-label {% if field.field.required %}requiredField{% endif %}">
                                {{ field.label }}{% if field.field.required and not field|is_checkbox %}<span class="asteriskField">*</span>{% endif %}
                            </th>
                        {% endif %}
                    {% endfor %}
                </tr>
            {% endif %}
        </thead>

        <tbody>
            <tr class="d-none empty-form">
                {% for field in formset.empty_form %}
                    {% include 'w3/field.html' with tag="td" form_show_labels=False %}
                {% endfor %}
            </tr>

            {% for form in formset %}
                {% if form_show_errors and not form.is_extra %}
                    {% include "w3/errors.html" %}
                {% endif %}

                <tr>
                    {% for field in form %}
                        {% include 'w3/field.html' with tag="td" form_show_labels=False %}
                    {% endfor %}
                </tr>
            {% endfor %}
        </tbody>
    </table>

    {% include "w3/inputs.html" %}

{% if formset_tag %}</form>{% endif %}
{% endspecialspaceless %}