form.html 1.9 KB

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