base_acl_macro.html.twig 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. {% macro render_form(form, permissions, td_type, admin, admin_pool, object) %}
  8. <form class="form-horizontal"
  9. action="{{ admin.generateUrl('acl', {'id': admin.id(object), 'uniqid': admin.uniqid, 'subclass': app.request.get('subclass')}) }}"
  10. {% if form.vars.multipart %} enctype="multipart/form-data"{% endif %}
  11. method="POST"
  12. {% if not admin_pool.getOption('html5_validate') %}novalidate="novalidate"{% endif %}
  13. >
  14. {{ include('SonataAdminBundle:Helper:render_form_dismissable_errors.html.twig') }}
  15. <div class="box box-success">
  16. <div class="body table-responsive no-padding">
  17. <table class="table">
  18. <colgroup>
  19. <col style="width: 100%;"/>
  20. {% for permission in permissions %}
  21. <col/>
  22. {% endfor %}
  23. </colgroup>
  24. {% for child in form.children if child.vars.name != '_token' %}
  25. {% if loop.index0 == 0 or loop.index0 % 10 == 0 %}
  26. <tr>
  27. <th>{{ td_type|trans({}, 'SonataAdminBundle') }}</th>
  28. {% for permission in permissions %}
  29. <th class="text-right">{{ permission }}</th>
  30. {% endfor %}
  31. </tr>
  32. {% endif %}
  33. <tr>
  34. <td>
  35. {% set typeChild = child['role'] is defined ? child['role'] : child['user'] %}
  36. {{ typeChild.vars.value }}
  37. {{ form_widget(typeChild) }}
  38. </td>
  39. {% for permission in permissions %}
  40. <td class="text-right">{{ form_widget(child[permission], { label: false }) }}</td>
  41. {% endfor %}
  42. </tr>
  43. {% endfor %}
  44. </table>
  45. </div>
  46. </div>
  47. {{ form_row(form._token) }}
  48. <div class="well well-small form-actions">
  49. <input class="btn btn-primary" type="submit" name="btn_create_and_edit" value="{{ 'btn_update_acl'|trans({}, 'SonataAdminBundle') }}">
  50. </div>
  51. </form>
  52. {% endmacro %}