base_edit.html.twig 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 title %}
  9. {% if admin.id(object) %}
  10. {{ "title_edit"|trans({'%name%': admin.toString(object) }, 'SonataAdminBundle') }}
  11. {% else %}
  12. {{ "title_create"|trans({}, 'SonataAdminBundle') }}
  13. {% endif %}
  14. {% endblock%}
  15. {% block actions %}
  16. <div class="sonata-actions">
  17. <ul>
  18. {% if admin.hasroute('show') and admin.id(object) and admin.isGranted('VIEW', object) and admin.show|length > 0 %}
  19. <li class="btn sonata-action-element"><a href="{{ admin.generateObjectUrl('show', object) }}">{% trans from 'SonataAdminBundle' %}link_action_show{% endtrans %}</a></li>
  20. {% endif %}
  21. {% if admin.hasroute('history') and admin.id(object) and admin.isGranted('EDIT', object) %}
  22. <li class="btn sonata-action-element"><a href="{{ admin.generateObjectUrl('history', object) }}">{% trans from 'SonataAdminBundle' %}link_action_history{% endtrans %}</a></li>
  23. {% endif %}
  24. {% if admin.hasroute('create') and admin.isGranted('CREATE') and admin.id(object)%}
  25. <li class="btn sonata-action-element"><a href="{{ admin.generateUrl('create') }}">{% trans from 'SonataAdminBundle' %}link_action_create{% endtrans %}</a></li>
  26. {% endif %}
  27. {% if admin.hasroute('list') and admin.isGranted('LIST')%}
  28. <li class="btn sonata-action-element"><a href="{{ admin.generateUrl('list') }}">{% trans from 'SonataAdminBundle' %}link_action_list{% endtrans %}</a></li>
  29. {% endif %}
  30. </ul>
  31. </div>
  32. {% endblock %}
  33. {% block side_menu %}{{ knp_menu_render(admin.sidemenu(action), {}, 'list') }}{% endblock %}
  34. {% block form %}
  35. {% set url = admin.id(object) ? 'edit' : 'create' %}
  36. {% if not admin.hasRoute(url)%}
  37. <div>
  38. {{ "form_not_available"|trans({}, "SonataAdminBundle") }}
  39. </div>
  40. {% else %}
  41. <form action="{{ admin.generateUrl(url, {'id': admin.id(object), 'uniqid': admin.uniqid}) }}" {{ form_enctype(form) }} method="POST">
  42. {% if form.vars.errors|length > 0 %}
  43. <div class="sonata-ba-form-error">
  44. {{ form_errors(form) }}
  45. </div>
  46. {% endif %}
  47. {% block sonata_pre_fieldsets %}{% endblock %}
  48. {% for name, form_group in admin.formgroups %}
  49. <fieldset {% if form_group.collapsed %}class="sonata-ba-fielset-collapsed"{% endif %}>
  50. <legend>
  51. {% if form_group.collapsed %}
  52. <a href="" class="sonata-ba-collapsed" title="{% trans from 'SonataAdminBundle' %}link_expand{% endtrans %}">{{ name|trans({}, admin.translationdomain) }}</a>
  53. {% else %}
  54. {{ name|trans({}, admin.translationdomain) }}
  55. {% endif %}
  56. </legend>
  57. <div class="sonata-ba-collapsed-fields">
  58. {% for field_name in form_group.fields %}
  59. {% if admin.formfielddescriptions[field_name] is defined %}
  60. {{ form_row(form[field_name])}}
  61. {% endif %}
  62. {% endfor %}
  63. </div>
  64. </fieldset>
  65. {% endfor %}
  66. {% block sonata_post_fieldsets %}{% endblock %}
  67. {{ form_rest(form) }}
  68. <div class="actions">
  69. {% if app.request.isxmlhttprequest %}
  70. {% if admin.id(object) %}
  71. <input type="submit" class="btn primary" name="btn_update" value="{% trans from 'SonataAdminBundle' %}btn_update{% endtrans %}"/>
  72. {% else %}
  73. <input type="submit" class="btn" name="btn_create" value="{% trans from 'SonataAdminBundle' %}btn_create{% endtrans %}"/>
  74. {% endif %}
  75. {% else %}
  76. {% if admin.id(object) %}
  77. <input type="submit" class="btn primary" name="btn_update_and_edit" value="{% trans from 'SonataAdminBundle' %}btn_update_and_edit_again{% endtrans %}"/>
  78. <input type="submit" class="btn" name="btn_update_and_list" value="{% trans from 'SonataAdminBundle' %}btn_update_and_return_to_list{% endtrans %}"/>
  79. {% if admin.hasroute('delete') and admin.isGranted('DELETE', object) %}
  80. {% trans from 'SonataAdminBundle' %}delete_or{% endtrans %}
  81. <a class="btn danger" href="{{ admin.generateObjectUrl('delete', object) }}">{% trans from 'SonataAdminBundle' %}link_delete{% endtrans %}</a>
  82. {% endif %}
  83. {% else %}
  84. <input class="btn primary" type="submit" name="btn_create_and_edit" value="{% trans from 'SonataAdminBundle' %}btn_create_and_edit_again{% endtrans %}"/>
  85. <input class="btn" type="submit" name="btn_create_and_create" value="{% trans from 'SonataAdminBundle' %}btn_create_and_create_a_new_one{% endtrans %}"/>
  86. {% endif %}
  87. {% endif %}
  88. </div>
  89. </form>
  90. {% endif%}
  91. {% endblock %}