You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

326 lines
15KB

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