base_edit.html.twig 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {#
  2. This file is part of the Sonata package.
  3. (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  4. For the full copyright and license information, please view the LICENSE
  5. file that was distributed with this source code.
  6. #}
  7. {% extends base_template %}
  8. {% block actions %}
  9. <div class="sonata-actions">
  10. <ul>
  11. <li class="sonata-action-element"><a href="{{ admin.generateUrl('create') }}">{% trans "link_action_create" from admin.translationdomain %}</a></li>
  12. <li class="sonata-action-element"><a href="{{ admin.generateUrl('list') }}">{% trans "link_action_list" from admin.translationdomain %}</a></li>
  13. </ul>
  14. </div>
  15. {% endblock %}
  16. {% block side_menu %}{% if side_menu %}{{ side_menu.render|raw }}{% endif %}{% endblock %}
  17. {% block form %}
  18. {% if object.id > 0 %}
  19. {% set url = 'edit' %}
  20. {% else %}
  21. {% set url = 'create' %}
  22. {% endif %}
  23. <form action="{{ admin.generateUrl(url, {'id': object.id, 'uniqid': admin.uniqid}) }}"{% if form.isMultipart %} enctype="multipart/form-data"{% endif %} method="POST">
  24. {{ form_hidden(form) }}
  25. {% if form.errors %}
  26. <div class="sonata-ba-form-error">
  27. {{ form_errors(form) }}
  28. </div>
  29. {% endif %}
  30. {% for name, form_group in form_groups %}
  31. {% if name %}
  32. <fieldset>
  33. <legend>
  34. {% trans name %}
  35. {% if form_group.collapsed %}
  36. <a href="" class="sonata-ba-collapsed">{% trans 'link_expand' from 'AdminBundle' %}</a>
  37. {% endif %}
  38. </legend>
  39. <div class="sonata-ba-collapsed-fields">
  40. {% endif %}
  41. {% for field_name in form_group.fields %}
  42. {% if fields[field_name] is defined %}
  43. {{ fields[field_name]|render_form_element(form, object) }}
  44. {% endif %}
  45. {% endfor %}
  46. {% if name %}
  47. </div>
  48. </fieldset>
  49. {% endif %}
  50. {% endfor %}
  51. {% if app.request.isxmlhttprequest %}
  52. {% if object.id %}
  53. <input type="submit" name="btn_update" value="{% trans "btn_update" from admin.translationdomain %}"/>
  54. {% else %}
  55. <input type="submit" name="btn_create" value="{% trans "btn_create" from admin.translationdomain %}"/>
  56. {% endif %}
  57. {% else %}
  58. {% if object.id %}
  59. <input type="submit" name="btn_update_and_edit" value="{% trans "btn_update_and_edit_again" from admin.translationdomain %}"/>
  60. <input type="submit" name="btn_update_and_list" value="{% trans "btn_update_and_return_to_list" from admin.translationdomain %}"/>
  61. {% else %}
  62. <input type="submit" name="btn_create_and_edit" value="{% trans "btn_create_and_edit_again" from admin.translationdomain %}"/>
  63. <input type="submit" name="btn_create_and_create" value="{% trans "btn_create_and_create_a_new_one" from admin.translationdomain %}"/>
  64. {% endif %}
  65. {% endif %}
  66. </form>
  67. {% endblock %}