base_edit_form.html.twig 5.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. {% block form %}
  2. {% set url = admin.id(object) ? 'edit' : 'create' %}
  3. {% if not admin.hasRoute(url)%}
  4. <div>
  5. {{ "form_not_available"|trans({}, "SonataAdminBundle") }}
  6. </div>
  7. {% else %}
  8. <form class="form-horizontal"
  9. action="{{ admin.generateUrl(url, {'id': admin.id(object), 'uniqid': admin.uniqid, 'subclass': app.request.get('subclass')}) }}" {{ form_enctype(form) }}
  10. method="POST"
  11. {% if not admin_pool.getOption('html5_validate') %}novalidate="novalidate"{% endif %}
  12. >
  13. {% if form.vars.errors|length > 0 %}
  14. <div class="sonata-ba-form-error">
  15. {{ form_errors(form) }}
  16. </div>
  17. {% endif %}
  18. {% block sonata_pre_fieldsets %}
  19. <div class="tabbable">
  20. <ul class="nav nav-tabs">
  21. {% for name, form_group in admin.formgroups %}
  22. <li class="{% if loop.first %}active{% endif %}">
  23. <a href="#{{ admin.uniqid }}_{{ loop.index }}" data-toggle="tab">
  24. <i class="icon-exclamation-sign has-errors hide"></i>
  25. {{ admin.trans(name, {}, form_group.translation_domain) }}
  26. </a>
  27. </li>
  28. {% endfor %}
  29. </ul>
  30. {% endblock %}
  31. <div class="tab-content">
  32. {% for name, form_group in admin.formgroups %}
  33. <div class="tab-pane {% if loop.first %} active{% endif %}" id="{{ admin.uniqid }}_{{ loop.index }}">
  34. <fieldset>
  35. <div class="sonata-ba-collapsed-fields">
  36. {% if form_group.description != false %}
  37. <p>{{ form_group.description|raw }}</p>
  38. {% endif %}
  39. {% for field_name in form_group.fields %}
  40. {% if admin.formfielddescriptions[field_name] is defined %}
  41. {{ form_row(form[field_name])}}
  42. {% endif %}
  43. {% endfor %}
  44. </div>
  45. </fieldset>
  46. </div>
  47. {% endfor %}
  48. </div>
  49. {% block sonata_post_fieldsets %}
  50. </div>
  51. {% endblock %}
  52. {{ form_rest(form) }}
  53. {% block formactions %}
  54. <div class="well form-actions">
  55. {% if app.request.isxmlhttprequest %}
  56. {% if admin.id(object) %}
  57. <input type="submit" class="btn btn-primary" name="btn_update" value="{{ 'btn_update'|trans({}, 'SonataAdminBundle') }}"/>
  58. {% else %}
  59. <input type="submit" class="btn" name="btn_create" value="{{ 'btn_create'|trans({}, 'SonataAdminBundle') }}"/>
  60. {% endif %}
  61. {% else %}
  62. {% if admin.supportsPreviewMode %}
  63. <button class="btn btn-info persist-preview" name="btn_preview" type="submit">
  64. <i class="icon-eye-open"></i>
  65. {{ 'btn_preview'|trans({}, 'SonataAdminBundle') }}
  66. </button>
  67. {% endif %}
  68. {% if admin.id(object) %}
  69. <input type="submit" class="btn btn-primary" name="btn_update_and_edit" value="{{ 'btn_update_and_edit_again'|trans({}, 'SonataAdminBundle') }}"/>
  70. {% if admin.hasroute('list') %}
  71. <input type="submit" class="btn" name="btn_update_and_list" value="{{ 'btn_update_and_return_to_list'|trans({}, 'SonataAdminBundle') }}"/>
  72. {% endif %}
  73. {% if admin.hasroute('delete') and admin.isGranted('DELETE', object) %}
  74. {{ 'delete_or'|trans({}, 'SonataAdminBundle') }}
  75. <a class="btn btn-danger" href="{{ admin.generateObjectUrl('delete', object) }}">{{ 'link_delete'|trans({}, 'SonataAdminBundle') }}</a>
  76. {% endif %}
  77. {% else %}
  78. <input class="btn btn-primary" type="submit" name="btn_create_and_edit" value="{{ 'btn_create_and_edit_again'|trans({}, 'SonataAdminBundle') }}"/>
  79. <input type="submit" class="btn" name="btn_create_and_list" value="{{ 'btn_create_and_return_to_list'|trans({}, 'SonataAdminBundle') }}"/>
  80. <input class="btn" type="submit" name="btn_create_and_create" value="{{ 'btn_create_and_create_a_new_one'|trans({}, 'SonataAdminBundle') }}"/>
  81. {% endif %}
  82. {% endif %}
  83. </div>
  84. {% endblock formactions %}
  85. </form>
  86. {% endif%}
  87. {% endblock %}