Posted By

fnl on 04/16/09


Tagged

textmate template django formset tabulated


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tclancy


Django formset tabulated fields (as in InlineTablular)


 / Published in: Other
 

  1. {{ formset.non_form_errors }}
  2. <table id="formset" class="form">
  3. {% for form in formset.forms %}
  4. {# TODO: showing form.non_field_errors #}
  5. {% if forloop.first %}
  6. <thead><tr>
  7. {% for field in form.visible_fields %}
  8. <th>{{ field.label|capfirst }}</th>
  9. {% endfor %}
  10. </tr></thead>
  11. {% endif %}
  12. <tr class="{% cycle row1,row2 %}">
  13. {% for field in form.visible_fields %}
  14. <td>
  15. {# Include the hidden fields in the form #}
  16. {% if forloop.first %}
  17. {% for hidden in form.hidden_fields %}
  18. {{ hidden }}
  19. {% endfor %}
  20. {% endif %}
  21. {{ field.errors.as_ul }}
  22. {{ field }}
  23. </td>
  24. {% endfor %}
  25. </tr>
  26. {% endfor %}
  27. </table>

Report this snippet  

You need to login to post a comment.