base_edit.html.twig 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. {% if admin.id(object) and admin.isGranted('VIEW') and admin.getViewFieldDescriptions is not empty %}
  12. <li class="sonata-action-element"><a href="{{ admin.generateUrl('view', {'id' : admin.id(object)}) }}">{% trans from 'SonataAdminBundle' %}link_action_view{% endtrans %}</a></li>
  13. {% endif %}
  14. {% if admin.isGranted('CREATE')%}
  15. <li class="sonata-action-element"><a href="{{ admin.generateUrl('create') }}">{% trans from 'SonataAdminBundle' %}link_action_create{% endtrans %}</a></li>
  16. {% endif %}
  17. {% if admin.isGranted('LIST')%}
  18. <li class="sonata-action-element"><a href="{{ admin.generateUrl('list') }}">{% trans from 'SonataAdminBundle' %}link_action_list{% endtrans %}</a></li>
  19. {% endif %}
  20. </ul>
  21. </div>
  22. {% endblock %}
  23. {% block side_menu %}{{ admin.sidemenu(action).render|raw }}{% endblock %}
  24. {% block form %}
  25. {% if admin.id(object) %}
  26. {% set url = 'edit' %}
  27. {% else %}
  28. {% set url = 'create' %}
  29. {% endif %}
  30. <form action="{{ admin.generateUrl(url, {'id': admin.id(object), 'uniqid': admin.uniqid}) }}" {{ form_enctype(form) }} method="POST">
  31. {% if form.vars.errors|length > 0 %}
  32. <div class="sonata-ba-form-error">
  33. {{ form_errors(form) }}
  34. </div>
  35. {% endif %}
  36. {% for name, form_group in admin.formgroups %}
  37. {% if name %}
  38. <fieldset>
  39. <legend>
  40. {{ name|trans({}, admin.translationdomain) }}
  41. {% if form_group.collapsed %}
  42. <a href="" class="sonata-ba-collapsed">{% trans from 'SonataAdminBundle' %}link_expand{% endtrans %}</a>
  43. {% endif %}
  44. </legend>
  45. <div class="sonata-ba-collapsed-fields">
  46. {% endif %}
  47. {% for field_name in form_group.fields %}
  48. {% if admin.formfielddescriptions[field_name] is defined %}
  49. {{ admin.formfielddescriptions[field_name]|render_form_element(form, object) }}
  50. {% endif %}
  51. {% endfor %}
  52. {% if name %}
  53. </div>
  54. </fieldset>
  55. {% endif %}
  56. {% endfor %}
  57. {{ form_rest(form) }}
  58. {% if app.request.isxmlhttprequest %}
  59. {% if admin.id(object) %}
  60. <input type="submit" name="btn_update" value="{% trans from 'SonataAdminBundle' %}btn_update{% endtrans %}"/>
  61. {% else %}
  62. <input type="submit" name="btn_create" value="{% trans from 'SonataAdminBundle' %}btn_create{% endtrans %}"/>
  63. {% endif %}
  64. {% else %}
  65. {% if admin.id(object) %}
  66. <input type="submit" name="btn_update_and_edit" value="{% trans from 'SonataAdminBundle' %}btn_update_and_edit_again{% endtrans %}"/>
  67. <input type="submit" name="btn_update_and_list" value="{% trans from 'SonataAdminBundle' %}btn_update_and_return_to_list{% endtrans %}"/>
  68. {% else %}
  69. <input type="submit" name="btn_create_and_edit" value="{% trans from 'SonataAdminBundle' %}btn_create_and_edit_again{% endtrans %}"/>
  70. <input type="submit" name="btn_create_and_create" value="{% trans from 'SonataAdminBundle' %}btn_create_and_create_a_new_one{% endtrans %}"/>
  71. {% endif %}
  72. {% endif %}
  73. </form>
  74. {% endblock %}