base_edit.html.twig 3.3 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 from admin.translationdomain %}link_action_create{% endtrans %}</a></li>
  12. <li class="sonata-action-element"><a href="{{ admin.generateUrl('list') }}">{% trans from admin.translationdomain %}link_action_list{% endtrans %}</a></li>
  13. </ul>
  14. </div>
  15. {% endblock %}
  16. {% block side_menu %}{{ admin.sidemenu(action).render|raw }}{% 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}) }}" {{ form_enctype(form) }} method="POST">
  24. {% if form.vars.errors|length > 0 %}
  25. <div class="sonata-ba-form-error">
  26. {{ form_errors(form) }}
  27. </div>
  28. {% endif %}
  29. {% for name, form_group in admin.formgroups %}
  30. {% if name %}
  31. <fieldset>
  32. <legend>
  33. {{ name|trans({}, admin.translationdomain) }}
  34. {% if form_group.collapsed %}
  35. <a href="" class="sonata-ba-collapsed">{% trans from 'AdminBundle' %}link_expand{% endtrans %}</a>
  36. {% endif %}
  37. </legend>
  38. <div class="sonata-ba-collapsed-fields">
  39. {% endif %}
  40. {% for field_name in form_group.fields %}
  41. {% if admin.formfielddescriptions[field_name] is defined %}
  42. {{ admin.formfielddescriptions[field_name]|render_form_element(form, object) }}
  43. {% endif %}
  44. {% endfor %}
  45. {% if name %}
  46. </div>
  47. </fieldset>
  48. {% endif %}
  49. {% endfor %}
  50. {{ form_rest(form) }}
  51. {% if app.request.isxmlhttprequest %}
  52. {% if object.id %}
  53. <input type="submit" name="btn_update" value="{% trans from admin.translationdomain %}btn_update{% endtrans %}"/>
  54. {% else %}
  55. <input type="submit" name="btn_create" value="{% trans from admin.translationdomain %}btn_create{% endtrans %}"/>
  56. {% endif %}
  57. {% else %}
  58. {% if object.id %}
  59. <input type="submit" name="btn_update_and_edit" value="{% trans from admin.translationdomain %}btn_update_and_edit_again{% endtrans %}"/>
  60. <input type="submit" name="btn_update_and_list" value="{% trans from admin.translationdomain %}btn_update_and_return_to_list{% endtrans %}"/>
  61. {% else %}
  62. <input type="submit" name="btn_create_and_edit" value="{% trans from admin.translationdomain %}btn_create_and_edit_again{% endtrans %}"/>
  63. <input type="submit" name="btn_create_and_create" value="{% trans from admin.translationdomain %}btn_create_and_create_a_new_one{% endtrans %}"/>
  64. {% endif %}
  65. {% endif %}
  66. </form>
  67. {% endblock %}