From f715a472d70f4601137b5efd81fd694eb2e0b856 Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Fri, 6 Mar 2020 14:37:25 +0100 Subject: [PATCH] Pure javascript for dynamically adding forms to formsets. Works, but id attributes are not properly incremented and will cause unknown trouble in the future. Strangely enough, it works for now! --- cms/templates/cms/edit.html | 102 ++++++++++++++++++++++++++---------- 1 file changed, 74 insertions(+), 28 deletions(-) diff --git a/cms/templates/cms/edit.html b/cms/templates/cms/edit.html index 06cbac8..afe2bd6 100644 --- a/cms/templates/cms/edit.html +++ b/cms/templates/cms/edit.html @@ -32,53 +32,99 @@ {% endif %} {% if formset %} - {{formset.management_form}} - {% for form in formset %} - {{form.media}} - {% for field in form.hidden_fields %} - {{field}} - {% endfor %} -
-
-
- {% for field in form.visible_fields %} - {% if field.name == 'DELETE' and not form.instance.pk %} - - {% elif field.field.widget.input_type == 'checkbox' %} - {% include 'cms/formfield_checkbox.html' with field=field counter=forloop.parentloop.counter0 %} - {% else %} - {% include 'cms/formfield.html' with field=field counter=forloop.parentloop.counter0 %} - {% endif %} - {% endfor %} -
+
+ {{formset.management_form}} + {% for form in formset %} +
+ {{form.media}} + {% for field in form.hidden_fields %} + {{field}} + {% endfor %} +
+
+
+ {% for field in form.visible_fields %} + {% if field.name == 'DELETE' and not form.instance.pk %} + + {% elif field.field.widget.input_type == 'checkbox' %} + {% include 'cms/formfield_checkbox.html' with field=field counter=forloop.parentloop.counter0 %} + {% else %} + {% include 'cms/formfield.html' with field=field counter=forloop.parentloop.counter0 %} + {% endif %} + {% endfor %} +
+
+
-
- {% endfor %} + {% endfor %} + + +
+
+ + +
+
{% endif %}
+ {% endblock %} {% block extrabody %}