base_edit.html.twig 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 }}
  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. {% if app.request.isxmlhttprequest %}
  51. {% if form.data.id %}
  52. <input type="submit" name="btn_update" value="{% trans from admin.translationdomain %}btn_update{% endtrans %}"/>
  53. {% else %}
  54. <input type="submit" name="btn_create" value="{% trans from admin.translationdomain %}btn_create{% endtrans %}"/>
  55. {% endif %}
  56. {% else %}
  57. {% if form.data.id %}
  58. <input type="submit" name="btn_update_and_edit" value="{% trans from admin.translationdomain %}btn_update_and_edit_again{% endtrans %}"/>
  59. <input type="submit" name="btn_update_and_list" value="{% trans from admin.translationdomain %}btn_update_and_return_to_list{% endtrans %}"/>
  60. {% else %}
  61. <input type="submit" name="btn_create_and_edit" value="{% trans from admin.translationdomain %}btn_create_and_edit_again{% endtrans %}"/>
  62. <input type="submit" name="btn_create_and_create" value="{% trans from admin.translationdomain %}btn_create_and_create_a_new_one{% endtrans %}"/>
  63. {% endif %}
  64. {% endif %}
  65. {{ form_rest(form) }}
  66. </form>
  67. {% endblock %}