Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

form_theme.html.twig 15KB

vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
  2. {% use '@EasyAdmin/crud/form_theme.html.twig' %}
  3. {% block form_start %}
  4. {% if form.vars.errors|length > 0 and 'ea_crud' in form.vars.block_prefixes|default([]) %}
  5. {{ form_errors(form) }}
  6. {% endif %}
  7. {%- do form.setMethodRendered() -%}
  8. {% set method = method|upper %}
  9. {%- if method in ["GET", "POST"] -%}
  10. {% set form_method = method %}
  11. {%- else -%}
  12. {% set form_method = "POST" %}
  13. {%- endif -%}
  14. <form{% if name != '' %} name="{{ name }}"{% endif %} method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{{ block('attributes') }}{% if multipart %} enctype="multipart/form-data"{% endif %}>
  15. {%- if form_method != method -%}
  16. <input type="hidden" name="_method" value="{{ method }}" />
  17. {%- endif -%}
  18. <input type="hidden" name="referrer" value="{% if ea is defined %}{{ ea.request.query.get('referrer') }}{% endif %}">
  19. {% endblock form_start %}
  20. {% block form_row %}
  21. {% set row_attr = row_attr|merge({
  22. class: row_attr.class|default('') ~ ' form-group'
  23. }) %}
  24. <div {% with { attr: row_attr } %}{{ block('attributes') }}{% endwith %}>
  25. {{- form_label(form) -}}
  26. <div class="form-widget">
  27. {#
  28. {% set has_prepend_html = ea.field.prepend_html|default(null) is not null %}
  29. {% set has_append_html = ea.field.append_html|default(null) is not null %}
  30. {% set has_input_groups = has_prepend_html or has_append_html %}
  31. #}
  32. {% set has_prepend_html = false %}
  33. {% set has_append_html = false %}
  34. {% set has_input_groups = false %}
  35. {% if ea_crud_form.ea_field is defined and ea_crud_form.ea_field is not null %}
  36. {% set prepend_html = ea_crud_form.ea_field.customOptions.get('prependHtml') %}
  37. {% set append_html = ea_crud_form.ea_field.customOptions.get('appendHtml') %}
  38. {% set has_prepend_html = prepend_html is not null %}
  39. {% set has_append_html = append_html is not null %}
  40. {% set has_input_groups = has_prepend_html or has_append_html %}
  41. {% endif %}
  42. {% if has_input_groups %}
  43. <div class="input-group">{% endif %}
  44. {% if has_prepend_html %}
  45. <div class="input-group-prepend">
  46. <span class="input-group-text">{{ prepend_html|raw }}</span>
  47. </div>
  48. {% endif %}
  49. {{ form_widget(form) }}
  50. {% if has_append_html %}
  51. <div class="input-group-append">
  52. <span class="input-group-text">{{ append_html|raw }}</span>
  53. </div>
  54. {% endif %}
  55. {% if has_input_groups %}</div>{% endif %}
  56. {% set nullable_fields_fqcn = [
  57. 'EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField',
  58. 'EasyCorp\Bundle\EasyAdminBundle\Field\DateField',
  59. 'EasyCorp\Bundle\EasyAdminBundle\Field\TimeField',
  60. ] %}
  61. {% if form.vars.ea_crud_form.ea_field.fieldFqcn|default(false) in nullable_fields_fqcn and ea.field.nullable|default(false) %}
  62. <div class="nullable-control">
  63. <label>
  64. <input type="checkbox" {% if data is null %}checked="checked"{% endif %}>
  65. {{ 'label.nullable_field'|trans({}, 'EasyAdminBundle') }}
  66. </label>
  67. </div>
  68. {% endif %}
  69. {% set help_message = name|sov_trans_admin_help(form.parent.vars.data) %}
  70. {% if help_message != '' %}
  71. <small class="form-help">{{ help_message }}</small>
  72. {% endif %}
  73. {{- form_errors(form) -}}
  74. </div>
  75. </div>
  76. {% endblock form_row %}
  77. {% block form_label -%}
  78. {% if label is same as(false) -%}
  79. <label>{# the empty <label> is needed to not break the form design #}</label>
  80. {%- else -%}
  81. {%- if compound is defined and compound -%}
  82. {%- set element = 'legend' -%}
  83. {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%}
  84. {%- else -%}
  85. {%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%}
  86. {%- endif -%}
  87. {% if required -%}
  88. {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %}
  89. {%- endif -%}
  90. {% if label is empty -%}
  91. {%- if label_format is not empty -%}
  92. {% set label = label_format|replace({
  93. '%name%': name,
  94. '%id%': id,
  95. }) %}
  96. {%- else -%}
  97. {# {% set label = name|humanize %} #}
  98. {%- endif -%}
  99. {%- endif -%}
  100. {% set entityNameOrObject = form.parent.vars.data %}
  101. {% if not entityNameOrObject and form.parent.vars.errors.form.config.dataClass is defined %}
  102. {% set entityNameOrObject = form.parent.vars.errors.form.config.dataClass %}
  103. {% endif %}
  104. <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|sov_trans_admin_field(entityNameOrObject) }}</{{ element|default('label') }}>
  105. {%- endif -%}
  106. {%- endblock form_label %}
  107. {% block gallery_manager_row %}
  108. {{ block('collection_row') }}
  109. {% endblock gallery_manager_row %}
  110. {% block gallery_manager_widget %}
  111. {{ block('collection_widget') }}
  112. {% endblock gallery_manager_widget %}
  113. {% block collection_row %}
  114. {% if prototype is defined and not prototype.rendered %}
  115. {% set row_attr = row_attr|merge({ 'data-prototype': form_row(prototype) }) %}
  116. {% endif %}
  117. {% set row_attr = row_attr|merge({
  118. 'data-entry-is-complex': form.vars.ea_crud_form.ea_field and form.vars.ea_crud_form.ea_field.customOptions.get('entryIsComplex') ? 'true' : 'false',
  119. 'data-allow-add': allow_add ? 'true' : 'false',
  120. 'data-allow-delete': allow_delete ? 'true' : 'false',
  121. 'data-num-items': form.children|length,
  122. 'data-form-type-name-placeholder': prototype is defined ? prototype.vars.name : '',
  123. }) %}
  124. {{ block('form_row') }}
  125. {% endblock collection_row %}
  126. {% block collection_widget %}
  127. {{ block('form_widget') }}
  128. {% if allow_add|default(false) %}
  129. <button type="button" class="btn btn-link field-collection-add">
  130. <i class="fa fa-plus pr-1"></i>
  131. {{ 'action.add_new_item'|trans({}, 'EasyAdminBundle') }}
  132. </button>
  133. {% endif %}
  134. {% endblock collection_widget %}
  135. {% block collection_entry_widget %}
  136. {% set is_complex = form_parent(form).vars.ea_crud_form.ea_field.customOptions.get('entryIsComplex') ?? false %}
  137. <div class="field-collection-item {{ is_complex ? 'field-collection-item-complex' }}">
  138. {% if form_parent(form).vars.allow_delete|default(false) %}
  139. <button type="button" class="btn btn-link field-collection-delete"
  140. title="{{ 'action.remove_item'|trans({}, 'EasyAdminBundle') }}">
  141. <i class="fas fa-times"></i>
  142. </button>
  143. {% endif %}
  144. {{ form_widget(form) }}
  145. </div>
  146. {% endblock collection_entry_widget %}
  147. {% block file_manager_image_row %}
  148. {{ form_widget(form) }}
  149. {% endblock file_manager_image_row %}
  150. {% block file_manager_legend_row %}
  151. {{ form_widget(form) }}
  152. {% endblock file_manager_legend_row %}
  153. {% block file_manager_position_row %}
  154. {{ form_widget(form) }}
  155. {% endblock file_manager_position_row %}
  156. {% block file_manager_widget %}
  157. {% if form.vars.ea_crud_form.ea_field is not null %}
  158. {% set managerDir = form.vars.ea_crud_form.ea_field.customOptions.get('managerDir') %}
  159. {% set type = form.vars.ea_crud_form.ea_field.customOptions.get('type') %}
  160. {% else %}
  161. {% if form.vars.attr.type is defined %}
  162. {% set managerDir = form.vars.attr.type %}
  163. {% set type = form.vars.attr.type %}
  164. {% endif %}
  165. {% endif %}
  166. {% if type is defined %}
  167. <div class="lc-filemanager row">
  168. {% if type == 'image' %}
  169. <div class="col-md-3 col-xs-12 form-group">
  170. <div class="lc-filemenager-preview card">
  171. <div class="no-image">
  172. <i class="fa fa-image"></i>
  173. </div>
  174. <img src="{{ form.path.vars.value }}" id="{{ form.path.vars.id }}_preview" alt=""
  175. class="card-img-top">
  176. </div>
  177. </div>
  178. {% else %}
  179. <div class="callout callout-success">
  180. <h5><i class="fa fa-file-alt"></i>
  181. <span id="{{ form.path.vars.id }}_preview_text">{{ form.path.vars.value }}</span>
  182. </h5>
  183. </div>
  184. {% endif %}
  185. <div class="col-12">
  186. {# {{ dump(form.vars) }}#}
  187. {# {{ dump(form.vars.ea_crud_form.ea_field) }}#}
  188. <div class="input-group">
  189. <div class="input-group-prepend">
  190. {% if form.parent.vars['row_attr']['data-sortable'] is defined %}
  191. <button type="button" class="btn btn-success lc-btn-sortable" data-toggle="tooltip"
  192. title="Trier les images">
  193. <i class="fa fa-arrows-alt"></i>
  194. </button>
  195. {% endif %}
  196. <button type="button" class="btn btn-primary lc-filemanager-open" data-id="{{ form.path.vars.id }}"
  197. data-toggle="tooltip" title="Sélectionner un fichier"
  198. data-target="{{ path('file_manager', {module:1, conf: managerDir})|raw }}">
  199. <i class="fa fa-folder-open"></i>
  200. </button>
  201. </div>
  202. {{ form_widget(form.legend) }}
  203. <div class="input-group-append">
  204. <button type="button" class="btn btn-danger lc-filemanager-delete" data-toggle="tooltip"
  205. title="Supprimer l'image"
  206. data-id="{{ form.path.vars.id }}">
  207. <i class="fa fa-trash"></i>
  208. </button>
  209. </div>
  210. {{ form_rest(form) }}
  211. </div>
  212. </div>
  213. </div>
  214. {% endif %}
  215. {% endblock file_manager_widget %}
  216. {% block checkbox_radio_label -%}
  217. {#- Do not display the label if widget is not defined in order to prevent double label rendering -#}
  218. {%- if widget is defined -%}
  219. {% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class or 'switch-custom' in parent_label_class) %}
  220. {% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class or 'switch-custom' in label_attr.class) %}
  221. {%- if is_parent_custom or is_custom -%}
  222. {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' custom-control-label')|trim}) -%}
  223. {%- else %}
  224. {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-check-label')|trim}) -%}
  225. {%- endif %}
  226. {%- if not compound -%}
  227. {% set label_attr = label_attr|merge({'for': id}) %}
  228. {%- endif -%}
  229. {%- if required -%}
  230. {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%}
  231. {%- endif -%}
  232. {%- if parent_label_class is defined -%}
  233. {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|replace({'checkbox-inline': '', 'radio-inline': '', 'checkbox-custom': '', 'radio-custom': ''})|trim}) -%}
  234. {%- endif -%}
  235. {%- if label is not same as(false) and label is empty -%}
  236. {%- if label_format is not empty -%}
  237. {%- set label = label_format|replace({
  238. '%name%': name,
  239. '%id%': id,
  240. }) -%}
  241. {%- else -%}
  242. {%- set label = name|humanize -%}
  243. {%- endif -%}
  244. {%- endif -%}
  245. <label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
  246. {{ widget|raw }}
  247. <span class="checkmark"></span>
  248. {# {{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain))|raw -}} #}
  249. {% set entityNameOrObject = form.parent.vars.data %}
  250. {% if not entityNameOrObject and form.parent.vars.errors.form.config.dataClass is defined %}
  251. {% set entityNameOrObject = form.parent.vars.errors.form.config.dataClass %}
  252. {% endif %}
  253. {{- (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|sov_trans_admin_field(entityNameOrObject) -}}
  254. {{- form_errors(form) -}}
  255. </label>
  256. {%- endif -%}
  257. {%- endblock checkbox_radio_label %}
  258. {% block ea_crud_widget_panels %}
  259. {% embed '@LcSov/adminlte/embed/tabs/tabs.html.twig' %}
  260. {# items menu #}
  261. {% import '@LcSov/adminlte/macro/tabs.html.twig' as mtabs %}
  262. {% block menu_items %}
  263. {% for panel_name, panel_config in ea_crud_form.form_panels|filter(panel_config => not panel_config.form_tab or panel_config.form_tab == tab_name) %}
  264. {{ mtabs.menu_item(panel_name, loop.first, panel_config.label|sov_trans_admin_panel(ea.getEntity().getFqcn())) }}
  265. {% endfor %}
  266. {% endblock %}
  267. {# content #}
  268. {% block content %}
  269. {# panes #}
  270. {% for panel_name, panel_config in ea_crud_form.form_panels|filter(panel_config => not panel_config.form_tab or panel_config.form_tab == tab_name) %}
  271. {% embed '@LcSov/adminlte/embed/tabs/pane.html.twig' %}
  272. {% block class %}{{ loop.first ? 'active' }}{% endblock %}
  273. {% block id %}{{ panel_name }}{% endblock %}
  274. {% block content %}
  275. {% for field in form|filter(field => 'hidden' not in field.vars.block_prefixes and field.vars.ea_crud_form.form_panel == panel_name) %}
  276. {% if not field.vars.ea_crud_form.form_tab or field.vars.ea_crud_form.form_tab == tab_name %}
  277. {{ form_row(field) }}
  278. {% endif %}
  279. {% endfor %}
  280. {% endblock %}
  281. {% endembed %}
  282. {% else %}
  283. {% for field in form|filter(field => 'hidden' not in field.vars.block_prefixes and (not field.vars.ea_crud_form.form_tab or field.vars.ea_crud_form.form_tab == tab_name)) %}
  284. {{ form_row(field) }}
  285. {% endfor %}
  286. {% endfor %}
  287. {% endblock %}
  288. {% endembed %}
  289. {% endblock ea_crud_widget_panels %}