base_edit.html.twig 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.hasroute('show') and admin.id(object) and admin.isGranted('VIEW') and admin.show|length > 0 %}
  12. <li class="sonata-action-element"><a href="{{ admin.generateObjectUrl('show', object) }}">{% trans from 'SonataAdminBundle' %}link_action_show{% endtrans %}</a></li>
  13. {% endif %}
  14. {% if admin.hasroute('create') and 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.hasroute('list') and 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 %}{{ knp_menu_render(admin.sidemenu(action), {}, 'list') }}{% endblock %}
  24. {% block form %}
  25. {% if admin.id(object) %}
  26. {% set url = 'edit' %}
  27. {% else %}
  28. {% set url = 'create' %}
  29. {% endif %}
  30. {% if not admin.hasRoute(url)%}
  31. <div>
  32. {{ "form_not_available"|trans({}, "SonataAdminBundle") }}
  33. </div>
  34. {% else %}
  35. <form action="{{ admin.generateUrl(url, {'id': admin.id(object), 'uniqid': admin.uniqid}) }}" {{ form_enctype(form) }} method="POST">
  36. {% if form.vars.errors|length > 0 %}
  37. <div class="sonata-ba-form-error">
  38. {{ form_errors(form) }}
  39. </div>
  40. {% endif %}
  41. {% for name, form_group in admin.formgroups %}
  42. {% if name %}
  43. <fieldset>
  44. <legend>
  45. {{ name|trans({}, admin.translationdomain) }}
  46. {% if form_group.collapsed %}
  47. <a href="" class="sonata-ba-collapsed">{% trans from 'SonataAdminBundle' %}link_expand{% endtrans %}</a>
  48. {% endif %}
  49. </legend>
  50. <div class="sonata-ba-collapsed-fields">
  51. {% endif %}
  52. {% for field_name in form_group.fields %}
  53. {% if admin.formfielddescriptions[field_name] is defined %}
  54. {{ form_row(form[field_name])}}
  55. {% endif %}
  56. {% endfor %}
  57. {% if name %}
  58. </div>
  59. </fieldset>
  60. {% endif %}
  61. {% endfor %}
  62. {{ form_rest(form) }}
  63. {% if app.request.isxmlhttprequest %}
  64. {% if admin.id(object) %}
  65. <input type="submit" name="btn_update" value="{% trans from 'SonataAdminBundle' %}btn_update{% endtrans %}"/>
  66. {% else %}
  67. <input type="submit" name="btn_create" value="{% trans from 'SonataAdminBundle' %}btn_create{% endtrans %}"/>
  68. {% endif %}
  69. {% else %}
  70. {% if admin.id(object) %}
  71. <input type="submit" name="btn_update_and_edit" value="{% trans from 'SonataAdminBundle' %}btn_update_and_edit_again{% endtrans %}"/>
  72. <input type="submit" name="btn_update_and_list" value="{% trans from 'SonataAdminBundle' %}btn_update_and_return_to_list{% endtrans %}"/>
  73. {% if admin.hasroute('delete') and admin.isGranted('DELETE') %}
  74. <a href="{{ admin.generateObjectUrl('delete', object) }}">{% trans from 'SonataAdminBundle' %}link_delete{% endtrans %}</a>
  75. {% endif %}
  76. {% else %}
  77. <input type="submit" name="btn_create_and_edit" value="{% trans from 'SonataAdminBundle' %}btn_create_and_edit_again{% endtrans %}"/>
  78. <input type="submit" name="btn_create_and_create" value="{% trans from 'SonataAdminBundle' %}btn_create_and_create_a_new_one{% endtrans %}"/>
  79. {% endif %}
  80. {% endif %}
  81. </form>
  82. {% endif%}
  83. {% endblock %}