1 {% load i18n adminmedia %}
2 {{ inline_admin_formset.formset.management_form }}
3 {% if inline_admin_formset.formset.forms %}
4 <div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
5 <div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
6 <fieldset class="module{% if inline_admin_formset.classes %} {{ inline_admin_formset.classes|join:' ' }}{% endif %}">
7 <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
8 {{ inline_admin_formset.formset.non_form_errors }}
11 {% for field in inline_admin_formset.fields %}
12 {% if not field.widget.is_hidden %}
13 <th{% if field.required %} class="required"{% endif %}>{{ field.label|capfirst }}</th>
16 {% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
20 {% for inline_admin_form in inline_admin_formset %}
21 {% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
22 {{ inline_admin_form.fk_field.field }}
24 {% for fieldset in inline_admin_form %}
25 {% for line in fieldset %}
26 {% for field in line %}
27 {% if field.is_hidden %} {{ field.field }} {% endif %}
31 {{ inline_admin_form.form.name.as_hidden }}
33 {% if inline_admin_form.form.non_field_errors %}
34 <tr><td colspan="{{ inline_admin_form.field_count }}">{{ inline_admin_form.form.non_field_errors }}</td></tr>
36 <tr class="{% cycle "row1" "row2" %} {% if forloop.last %} empty-form{% endif %}"
37 id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
38 <th>{{ inline_admin_form.form.verbose_name|capfirst }}:</th>
39 {% for fieldset in inline_admin_form %}
40 {% for line in fieldset %}
41 {% for field in line %}
42 {% if field.field.name != 'name' %}
43 <td class="{{ field.field.name }}">
44 {% if field.is_readonly %}
45 <p>{{ field.contents }}</p>
47 {{ field.field.errors.as_ul }}
55 {% if inline_admin_formset.formset.can_delete %}
56 <td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>
66 <script type="text/javascript">
68 $(document).ready(function($) {
69 var rows = "#{{ inline_admin_formset.formset.prefix }}-group .tabular.inline-related tbody tr";
70 var alternatingRows = function(row) {
71 $(rows).not(".add-row").removeClass("row1 row2")
72 .filter(":even").addClass("row1").end()
73 .filter(rows + ":odd").addClass("row2");
75 var reinitDateTimeShortCuts = function() {
76 // Reinitialize the calendar and clock widgets by force
77 if (typeof DateTimeShortcuts != "undefined") {
78 $(".datetimeshortcuts").remove();
79 DateTimeShortcuts.init();
82 var updateSelectFilter = function() {
83 // If any SelectFilter widgets are a part of the new form,
84 // instantiate a new SelectFilter instance for it.
85 if (typeof SelectFilter != "undefined"){
86 $(".selectfilter").each(function(index, value){
87 var namearr = value.name.split('-');
88 SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% admin_media_prefix %}");
90 $(".selectfilterstacked").each(function(index, value){
91 var namearr = value.name.split('-');
92 SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% admin_media_prefix %}");
96 var initPrepopulatedFields = function(row) {
97 row.find('.prepopulated_field').each(function() {
99 var input = field.find('input, select, textarea');
100 var dependency_list = input.data('dependency_list') || [];
101 var dependencies = row.find(dependency_list.join(',')).find('input, select, textarea');
102 if (dependencies.length) {
103 input.prepopulate(dependencies, input.attr('maxlength'));
108 prefix: "{{ inline_admin_formset.formset.prefix }}",
109 addText: "{% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
110 formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}",
111 deleteCssClass: "inline-deletelink",
112 deleteText: "{% trans "Remove" %}",
113 emptyCssClass: "empty-form",
114 removed: alternatingRows,
115 added: (function(row) {
116 initPrepopulatedFields(row);
117 reinitDateTimeShortCuts();
118 updateSelectFilter();
119 alternatingRows(row);