base_edit_form.html.twig 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. {% block form %}
  2. {% set url = admin.id(object) is not null ? '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. {% block sonata_tab_content %}
  32. <div class="tab-content">
  33. {% for name, form_group in admin.formgroups %}
  34. <div class="tab-pane {% if loop.first %} active{% endif %}" id="{{ admin.uniqid }}_{{ loop.index }}">
  35. <fieldset>
  36. <div class="sonata-ba-collapsed-fields">
  37. {% if form_group.description != false %}
  38. <p>{{ form_group.description|raw }}</p>
  39. {% endif %}
  40. {% for field_name in form_group.fields %}
  41. {% if admin.formfielddescriptions[field_name] is defined %}
  42. {{ form_row(form[field_name])}}
  43. {% endif %}
  44. {% endfor %}
  45. </div>
  46. </fieldset>
  47. </div>
  48. {% endfor %}
  49. </div>
  50. {% endblock %}
  51. {% block sonata_post_fieldsets %}
  52. </div>
  53. {% endblock %}
  54. {{ form_rest(form) }}
  55. {% block formactions %}
  56. <div class="well well-small form-actions">
  57. {% if app.request.isxmlhttprequest %}
  58. {% if admin.id(object) is not null %}
  59. <input type="submit" class="btn btn-primary" name="btn_update" value="{{ 'btn_update'|trans({}, 'SonataAdminBundle') }}"/>
  60. {% else %}
  61. <input type="submit" class="btn" name="btn_create" value="{{ 'btn_create'|trans({}, 'SonataAdminBundle') }}"/>
  62. {% endif %}
  63. {% else %}
  64. {% if admin.supportsPreviewMode %}
  65. <button class="btn btn-info persist-preview" name="btn_preview" type="submit">
  66. <i class="icon-eye-open"></i>
  67. {{ 'btn_preview'|trans({}, 'SonataAdminBundle') }}
  68. </button>
  69. {% endif %}
  70. {% if admin.id(object) is not null %}
  71. <input type="submit" class="btn btn-primary" name="btn_update_and_edit" value="{{ 'btn_update_and_edit_again'|trans({}, 'SonataAdminBundle') }}"/>
  72. {% if admin.hasroute('list') %}
  73. <input type="submit" class="btn" name="btn_update_and_list" value="{{ 'btn_update_and_return_to_list'|trans({}, 'SonataAdminBundle') }}"/>
  74. {% endif %}
  75. {% if admin.hasroute('delete') and admin.isGranted('DELETE', object) %}
  76. {{ 'delete_or'|trans({}, 'SonataAdminBundle') }}
  77. <a class="btn btn-danger" href="{{ admin.generateObjectUrl('delete', object) }}">{{ 'link_delete'|trans({}, 'SonataAdminBundle') }}</a>
  78. {% endif %}
  79. {% if admin.isAclEnabled() and admin.hasroute('acl') and admin.isGranted('MASTER', object) %}
  80. <a class="btn" href="{{ admin.generateObjectUrl('acl', object) }}">{{ 'link_edit_acl'|trans({}, 'SonataAdminBundle') }}</a>
  81. {% endif %}
  82. {% else %}
  83. {% if admin.hasroute('edit') %}
  84. <input class="btn btn-primary" type="submit" name="btn_create_and_edit" value="{{ 'btn_create_and_edit_again'|trans({}, 'SonataAdminBundle') }}"/>
  85. {% endif %}
  86. {% if admin.hasroute('list') %}
  87. <input type="submit" class="btn" name="btn_create_and_list" value="{{ 'btn_create_and_return_to_list'|trans({}, 'SonataAdminBundle') }}"/>
  88. {% endif %}
  89. <input class="btn" type="submit" name="btn_create_and_create" value="{{ 'btn_create_and_create_a_new_one'|trans({}, 'SonataAdminBundle') }}"/>
  90. {% endif %}
  91. {% endif %}
  92. </div>
  93. {% endblock formactions %}
  94. </form>
  95. {% endif%}
  96. {% endblock %}