No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

351 líneas
16KB

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