您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

371 行
17KB

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