Statistics
| Branch: | Revision:

root / env / lib / python2.7 / site-packages / django / contrib / admin / templates / admin / prepopulated_fields_js.html @ 1a305335

History | View | Annotate | Download (1012 Bytes)

1
{% load l10n %}
2
<script type="text/javascript">
3
(function($) {
4
    var field;
5

6
{% for field in prepopulated_fields %}
7
    field = {
8
        id: '#{{ field.field.auto_id }}',
9
        dependency_ids: [],
10
        dependency_list: [],
11
        maxLength: {{ field.field.field.max_length|default_if_none:"50"|unlocalize }}
12
    };
13

14
    {% for dependency in field.dependencies %}
15
    field['dependency_ids'].push('#{{ dependency.auto_id }}');
16
    field['dependency_list'].push('{{ dependency.name }}');
17
    {% endfor %}
18

19
    {% comment %}
20
    Mark prepopulated fields in the main form and stacked inlines (.empty-form .form-row) and in tabular inlines (.empty-form.form-row)
21
    {% endcomment %}
22
    $('.empty-form .form-row .field-{{ field.field.name }}, .empty-form.form-row .field-{{ field.field.name }}').addClass('prepopulated_field');
23
    $(field.id).data('dependency_list', field['dependency_list'])
24
               .prepopulate(field['dependency_ids'], field.maxLength);
25
{% endfor %}
26
})(django.jQuery);
27
</script>