form.html 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. {% extends "admin/admin/layout.html" %}
  2. {% load i18n %}
  3. {% load l10n %}
  4. {% load url from future %}
  5. {% import "_forms.html" as form_theme with context %}
  6. {% block action_body %}
  7. <form action="{{ url }}" method="post">
  8. {% if tabbed %}
  9. {{ form_theme.form_hidden_widget(form) }}
  10. <ul class="nav nav-tabs" id="form-tabs">{% for fieldset in form.fieldsets %}
  11. <li{% if loop.first %} class="active"{% endif%}><a href="#form-tab-{{ loop.index }}" data-toggle="tab">{{ fieldset.legend }}</a></li>{% endfor %}
  12. </ul>
  13. <div class="tab-content">
  14. {% for fieldset in form.fieldsets %}
  15. <div class="tab-pane{% if loop.first %} active{% endif%}" id="form-tab-{{ loop.index }}">
  16. <fieldset>
  17. <legend>{{ fieldset.legend }}</legend>{% for field in fieldset.fields %}
  18. {{ form_theme.row_widget(field) }}{% endfor %}
  19. </fieldset>
  20. </div>
  21. {% endfor %}
  22. </div>
  23. {% else %}
  24. {{ form_theme.form_widget(form) }}
  25. {% endif %}
  26. <div class="form-actions">
  27. {% block form_actions %}
  28. {% block form_submit %}
  29. <button name="save" type="submit" class="btn btn-primary">{{ action.submit_button }}</button>
  30. {% endblock %}
  31. {% if action.get_edit_url -%}
  32. <button name="save_edit" type="submit" class="btn btn-warning">{% trans %}Save and Edit{% endtrans %}</button>
  33. {%- endif %}
  34. {% if action.get_new_url -%}
  35. <button name="save_new" type="submit" class="btn btn-success">{% trans %}Save and Add Another{% endtrans %}</button>
  36. {%- endif %}
  37. {% if fallback %}<a href="{{ fallback }}" class="btn">{% trans %}Cancel{% endtrans %}</a>{% endif %}
  38. {% endblock %}
  39. </div>
  40. </form>
  41. {% endblock %}
  42. {% block javascripts %}
  43. {{ super() }}
  44. {% if tabbed %}
  45. <script>
  46. $(function () {
  47. $('#form-tabs a').click(function (e) {
  48. e.preventDefault();
  49. $(this).tab('show');
  50. });
  51. });
  52. </script>
  53. {% endif %}
  54. {% endblock %}