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 inline_admin_form in inline_admin_formset %}
12 {% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
13 {{ inline_admin_form.fk_field.field }}
15 {% for fieldset in inline_admin_form %}
16 {% for line in fieldset %}
17 {% for field in line %}
18 {% if field.is_hidden %} {{ field.field }} {% endif %}
24 {% for form in inline_admin_formset.formset.forms %}
25 {% if form.non_field_errors %}
26 <tr><td colspan="2">{{ form.non_field_errors }}</td></tr>
28 <tr class="{% cycle "row1" "row2" %}{% comment %} {% if forloop.last %} empty-form{% endif %}{% endcomment %}"
29 id="{{ formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
30 <th>{{ form.verbose_name|capfirst }}:</th>
31 {% for field in form %}
32 {% if not field.is_hidden %}
33 <td class="{{ field.field.name }}">
34 {{ field.field.errors.as_ul }}
36 {% if field.field.help_text %}
37 <p class="help">{{ field.field.help_text|safe }}</p>
50 <script type="text/javascript">
52 $(document).ready(function($) {
53 var rows = "#{{ inline_admin_formset.formset.prefix }}-group .tabular.inline-related tbody tr";
54 var alternatingRows = function(row) {
55 $(rows).not(".add-row").removeClass("row1 row2")
56 .filter(":even").addClass("row1").end()
57 .filter(rows + ":odd").addClass("row2");
59 var reinitDateTimeShortCuts = function() {
60 // Reinitialize the calendar and clock widgets by force
61 if (typeof DateTimeShortcuts != "undefined") {
62 $(".datetimeshortcuts").remove();
63 DateTimeShortcuts.init();
66 var updateSelectFilter = function() {
67 // If any SelectFilter widgets are a part of the new form,
68 // instantiate a new SelectFilter instance for it.
69 if (typeof SelectFilter != "undefined"){
70 $(".selectfilter").each(function(index, value){
71 var namearr = value.name.split('-');
72 SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% admin_media_prefix %}");
74 $(".selectfilterstacked").each(function(index, value){
75 var namearr = value.name.split('-');
76 SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% admin_media_prefix %}");
80 var initPrepopulatedFields = function(row) {
81 row.find('.prepopulated_field').each(function() {
83 var input = field.find('input, select, textarea');
84 var dependency_list = input.data('dependency_list') || [];
85 var dependencies = row.find(dependency_list.join(',')).find('input, select, textarea');
86 if (dependencies.length) {
87 input.prepopulate(dependencies, input.attr('maxlength'));
92 prefix: "{{ inline_admin_formset.formset.prefix }}",
93 addText: "{% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
94 formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}",
95 deleteCssClass: "inline-deletelink",
96 deleteText: "{% trans "Remove" %}",
97 emptyCssClass: "empty-form",
98 removed: alternatingRows,
99 added: (function(row) {
100 initPrepopulatedFields(row);
101 reinitDateTimeShortCuts();
102 updateSelectFilter();
103 alternatingRows(row);