[Answer]-Dynamic formset problems

1👍

It looks like you took javascript from this question, but that you did not adapt your HTML structure.

As I can see in your snippet (which also looks like it will produce highly invalid html, ie. tr in divs):

{% for attendee in attendees.forms %}
<div class="formgroup">
  {{ attendee }}
  {% if attendee.nested %}
  {% for formset in attendee.nested %}
  {{ formset.as_table }}
  {% endfor %} 
  {% endif %} 
</div>
{% endfor %}

And his:

{{ serviceFormset.management_form }}
{% for form in serviceFormset.forms %}
    <div class='table'>
    <table class='no_error'>
        {{ form.as_table }}
    </table>
    </div>
{% endfor %}

If you want the same exact javascript piece of code, then you should have the same exact HTML structure. The first thing you’re doing in JS is passing div.table:last as selector but you have no div.table in your HTML.

Your best bet is to try to make the javascript yourself. As a webpage developer, javascript will help you a lot.

👤jpic

Leave a comment