vendor/easycorp/easyadmin-bundle/src/Resources/views/crud/detail.html.twig line 1

Open in your IDE?
  1. {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
  2. {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
  3. {% extends ea.templatePath('layout') %}
  4. {% block body_id 'ea-detail-' ~ entity.name ~ '-' ~ entity.primaryKeyValue %}
  5. {% block body_class 'ea-detail ea-detail-' ~ entity.name %}
  6. {% set ea_field_assets = ea.crud.fieldAssets(constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Crud::PAGE_DETAIL')) %}
  7. {% block configured_head_contents %}
  8.     {{ parent() }}
  9.     {% for htmlContent in ea_field_assets.headContents %}
  10.         {{ htmlContent|raw }}
  11.     {% endfor %}
  12. {% endblock %}
  13. {% block configured_body_contents %}
  14.     {{ parent() }}
  15.     {% for htmlContent in ea_field_assets.bodyContents %}
  16.         {{ htmlContent|raw }}
  17.     {% endfor %}
  18. {% endblock %}
  19. {% block configured_stylesheets %}
  20.     {{ parent() }}
  21.     {{ include('@EasyAdmin/includes/_css_assets.html.twig', { assets: ea_field_assets.cssAssets }, with_context = false) }}
  22.     {{ include('@EasyAdmin/includes/_encore_link_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }}
  23. {% endblock %}
  24. {% block configured_javascripts %}
  25.     {{ parent() }}
  26.     {{ include('@EasyAdmin/includes/_js_assets.html.twig', { assets: ea_field_assets.jsAssets }, with_context = false) }}
  27.     {{ include('@EasyAdmin/includes/_encore_script_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }}
  28. {% endblock %}
  29. {% block content_title %}
  30.     {%- set custom_page_title = ea.crud.customPageTitle(pageName, entity ? entity.instance : null, ea.i18n.translationParameters, ea.i18n.translationDomain) -%}
  31.     {{- custom_page_title is null
  32.         ? ea.crud.defaultPageTitle(null, null, ea.i18n.translationParameters)|trans|raw
  33.         : custom_page_title|trans|raw -}}
  34. {% endblock %}
  35. {% block page_actions %}
  36.     {% for action in entity.actions %}
  37.         {{ include(action.templatePath, { action: action }, with_context = false) }}
  38.     {% endfor %}
  39. {% endblock %}
  40. {% block main %}
  41.     {% block detail_fields %}
  42.         {% for field in entity.fields %}
  43.             {% if field.isFormLayoutField %}
  44.                 {{ _self.render_layout_field(field) }}
  45.             {% else %}
  46.                 {{ _self.render_field_contents(entity, field) }}
  47.             {% endif %}
  48.         {% endfor %}
  49.     {% endblock detail_fields %}
  50.     {% block delete_form %}
  51.         {{ include('@EasyAdmin/crud/includes/_delete_form.html.twig', { entity_id: entity.primaryKeyValue }, with_context = false) }}
  52.     {% endblock delete_form %}
  53. {% endblock %}
  54. {% macro render_field_contents(entity, field) %}
  55.     <div class="field-group {{ field.cssClass }}">
  56.         {% if field.label is same as (false) %}
  57.             {# a FALSE label value means that the field doesn't even display the <label> element;
  58.                use an empty string to not display a label but keep the <label> element to not mess with the layout #}
  59.         {% else %}
  60.             <div class="field-label">
  61.                 {%- set label_html_attributes -%}
  62.                     {%- if field.help is not empty -%}
  63.                         data-bs-toggle="tooltip" data-bs-placement="auto" data-bs-animation="false"
  64.                         data-bs-html="true" data-bs-custom-class="ea-detail-label-tooltip"
  65.                         data-bs-title="{{ field.help|trans|e('html_attr') }}"
  66.                     {%- endif -%}
  67.                 {%- endset -%}
  68.                 <div {{ label_html_attributes }}>
  69.                     {{ field.label|trans|raw }}
  70.                 </div>
  71.             </div>
  72.         {% endif %}
  73.         <div class="field-value">
  74.             {{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }}
  75.         </div>
  76.     </div>
  77. {% endmacro %}
  78. {% macro render_layout_field(field) %}
  79.     {% if field.formType == 'EasyCorp\\Bundle\\EasyAdminBundle\\Form\\Type\\Layout\\EaFormTabListType' %}
  80.         {{ _self.render_tab_list(field) }}
  81.     {% elseif field.formType == 'EasyCorp\\Bundle\\EasyAdminBundle\\Form\\Type\\Layout\\EaFormTabPaneGroupOpenType' %}
  82.         {{ _self.render_tab_group_open(field) }}
  83.     {% elseif field.formType == 'EasyCorp\\Bundle\\EasyAdminBundle\\Form\\Type\\Layout\\EaFormTabPaneGroupCloseType' %}
  84.         {{ _self.render_tab_group_close(field) }}
  85.     {% elseif field.formType == 'EasyCorp\\Bundle\\EasyAdminBundle\\Form\\Type\\Layout\\EaFormTabPaneOpenType' %}
  86.         {{ _self.render_tab_open(field) }}
  87.     {% elseif field.formType == 'EasyCorp\\Bundle\\EasyAdminBundle\\Form\\Type\\Layout\\EaFormTabPaneCloseType' %}
  88.         {{ _self.render_tab_close(field) }}
  89.     {% elseif field.formType == 'EasyCorp\\Bundle\\EasyAdminBundle\\Form\\Type\\Layout\\EaFormColumnGroupOpenType' %}
  90.         {{ _self.render_column_group_open(field) }}
  91.     {% elseif field.formType == 'EasyCorp\\Bundle\\EasyAdminBundle\\Form\\Type\\Layout\\EaFormColumnGroupCloseType' %}
  92.         {{ _self.render_column_group_close(field) }}
  93.     {% elseif field.formType == 'EasyCorp\\Bundle\\EasyAdminBundle\\Form\\Type\\Layout\\EaFormColumnOpenType' %}
  94.         {{ _self.render_column_open(field) }}
  95.     {% elseif field.formType == 'EasyCorp\\Bundle\\EasyAdminBundle\\Form\\Type\\Layout\\EaFormColumnCloseType' %}
  96.         {{ _self.render_column_close(field) }}
  97.     {% elseif field.formType == 'EasyCorp\\Bundle\\EasyAdminBundle\\Form\\Type\\Layout\\EaFormFieldsetOpenType' %}
  98.         {{ _self.render_fieldset_open(field) }}
  99.     {% elseif field.formType == 'EasyCorp\\Bundle\\EasyAdminBundle\\Form\\Type\\Layout\\EaFormFieldsetCloseType' %}
  100.         {{ _self.render_fieldset_close(field) }}
  101.     {% endif %}
  102. {% endmacro %}
  103. {% macro render_tab_list(field) %}
  104.     {% set tab_id_option_name = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Field\\FormField::OPTION_TAB_ID') %}
  105.     {% set tab_is_active_option_name = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Field\\FormField::OPTION_TAB_IS_ACTIVE') %}
  106.     {% set tab_error_count_option_name = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Field\\FormField::OPTION_TAB_ERROR_COUNT') %}
  107.     <div class="nav-tabs-custom form-tabs-tablist">
  108.         <ul class="nav nav-tabs">
  109.             {% for tab in field.getCustomOption('tabs') %}
  110.                 <li class="nav-item">
  111.                     <a class="nav-link {% if tab.getCustomOption(tab_is_active_option_name) %}active{% endif %}" href="#{{ tab.getCustomOption(tab_id_option_name) }}" id="tablist-{{ tab.getCustomOption(tab_id_option_name) }}" data-bs-toggle="tab">
  112.                         {%- if tab.getCustomOption('icon')|default(false) -%}
  113.                             <i class="tab-nav-item-icon fa-fw {{ tab.getCustomOption('icon') }}"></i>
  114.                         {%- endif -%}
  115.                         {{ tab.label|trans(domain = ea.i18n.translationDomain)|raw }}
  116.                         {% set tab_error_count = tab.getCustomOption(tab_error_count_option_name)  %}
  117.                         {%- if tab_error_count > 0 -%}
  118.                             <span class="badge badge-danger" title="{{ 'form.tab.error_badge_title'|trans({'%count%': tab_error_count}, 'EasyAdminBundle') }}">
  119.                                 {{- tab_error_count -}}
  120.                             </span>
  121.                         {%- endif -%}
  122.                     </a>
  123.                 </li>
  124.             {% endfor %}
  125.         </ul>
  126.     </div>
  127. {% endmacro %}
  128. {% macro render_tab_group_open(field) %}
  129.     <div class="nav-tabs-custom form-tabs-content">
  130.         <div class="tab-content">
  131. {% endmacro %}
  132. {% macro render_tab_group_close(field) %}
  133.         </div>
  134.     </div>
  135. {% endmacro %}
  136. {% macro render_tab_open(field) %}
  137.     {% set tab_id_option_name = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Field\\FormField::OPTION_TAB_ID') %}
  138.     {% set tab_is_active_option_name = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Field\\FormField::OPTION_TAB_IS_ACTIVE') %}
  139.     <div id="{{ field.getCustomOption(tab_id_option_name) }}" class="tab-pane {% if field.getCustomOption(tab_is_active_option_name) %}active{% endif %} {{ field.cssClass }}" {% for key, value in field.getFormTypeOption('attr') %}{{ key }}="{{ value|e('html_attr') }}"{% endfor %}>
  140.         {% if field.help %}
  141.             <div class="content-header-help tab-help">
  142.                 {{ field.help|trans(domain = ea.i18n.translationDomain)|raw }}
  143.             </div>
  144.         {% endif %}
  145.         <div class="row">
  146. {% endmacro %}
  147. {% macro render_tab_close(field) %}
  148.         </div>
  149.     </div>
  150. {% endmacro %}
  151. {% macro render_column_group_open(field) %}
  152.     {# if columns are inside tabs, don't add a '.row' element because the tab pane already opens it #}
  153.     {% if not field.getFormTypeOption('ea_is_inside_tab')|default(false) %}
  154.         <div class="row">
  155.     {% endif %}
  156. {% endmacro %}
  157. {% macro render_column_group_close(field) %}
  158.     {# if columns are inside tabs, don't add a '.row' element because the tab pane already opens it #}
  159.     {% if not field.getFormTypeOption('ea_is_inside_tab')|default(false) %}
  160.         </div>
  161.     {% endif %}
  162. {% endmacro %}
  163. {% macro render_column_open(field) %}
  164.     {% set field_icon = field.getCustomOption('icon') %}
  165.     {% set column_has_title = field_icon != null or field.label != false or field.label != null or field.label != '' or field.help != null %}
  166.     <div class="form-column {{ not column_has_title ? 'form-column-no-header' }} {{ field.cssClass }}">
  167.         {% if column_has_title %}
  168.             <div class="form-column-title">
  169.                 <div class="form-column-title-content">
  170.                     {% if field_icon %}<i class="form-column-icon fa fa-fw fa-{{ field_icon }}"></i>{% endif %}
  171.                     {% if field.label %}{{ field.label|trans(domain = ea.i18n.translationDomain)|raw }}{% endif %}
  172.                 </div>
  173.                 {% if field.help %}
  174.                     <div class="form-column-help">{{ field.help|trans(domain = ea.i18n.translationDomain)|raw }}</div>
  175.                 {% endif %}
  176.             </div>
  177.         {% endif %}
  178. {% endmacro %}
  179. {% macro render_column_close(field) %}
  180.     </div>
  181. {% endmacro %}
  182. {% macro render_fieldset_open(field) %}
  183.     {% set fieldset_has_header = field.label or field.getCustomOption('icon') or field.help %}
  184.     {% set is_collapsible_option_name = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Field\\FormField::OPTION_COLLAPSIBLE') %}
  185.     {% set is_collapsed_option_name = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Field\\FormField::OPTION_COLLAPSED') %}
  186.     {% set is_collapsible = field.getCustomOption(is_collapsible_option_name) %}
  187.     {% set is_collapsed = field.getCustomOption(is_collapsed_option_name) %}
  188.     <div class="form-fieldset {{ not fieldset_has_header ? 'form-fieldset-no-header' }} {{ field.cssClass }}">
  189.         <fieldset>
  190.             {% if fieldset_has_header %}
  191.                 <div class="form-fieldset-header {{ is_collapsible ? 'collapsible' }} {{ field.help is not empty ? 'with-help' }}">
  192.                     <div class="form-fieldset-title">
  193.                         {% set fieldset_title_contents %}
  194.                             {% if is_collapsible %}
  195.                                 <i class="fas fw fa-chevron-right form-fieldset-collapse-marker"></i>
  196.                             {% endif %}
  197.                             {% if field.getCustomOption('icon') %}
  198.                                 <i class="form-fieldset-icon {{ field.getCustomOption('icon') }}"></i>
  199.                             {% endif %}
  200.                             {{ field.label|trans|raw }}
  201.                         {% endset %}
  202.                         {% if is_collapsible %}
  203.                             <a href="#content-{{ field.property }}" data-bs-toggle="collapse"
  204.                                class="form-fieldset-title-content form-fieldset-collapse {{ is_collapsed ? 'collapsed' }}"
  205.                                aria-expanded="{{ is_collapsed ? 'false' : 'true' }}" aria-controls="content-{{ field.property }}">
  206.                                 {{ fieldset_title_contents|raw }}
  207.                             </a>
  208.                         {% else %}
  209.                             <span class="not-collapsible form-fieldset-title-content">
  210.                                 {{ fieldset_title_contents|raw }}
  211.                             </span>
  212.                         {% endif %}
  213.                         {% if field.help %}
  214.                             <div class="form-fieldset-help">{{ field.help|trans|raw }}</div>
  215.                         {% endif %}
  216.                     </div>
  217.                 </div>
  218.             {% endif %}
  219.             <div id="content-{{ field.property }}" class="form-fieldset-body {{ not fieldset_has_header ? 'without-header' }} {{ is_collapsible ? 'collapse' }} {{ not is_collapsed ? 'show'}}">
  220.                 <div class="row">
  221. {% endmacro %}
  222. {% macro render_fieldset_close(field) %}
  223.                 </div>
  224.             </div>
  225.         </fieldset>
  226.     </div>
  227. {% endmacro %}
  228. {% macro render_detail_fields_with_tabs(entity, field_layout) %}
  229.     {% deprecated 'The "render_detail_fields_with_tabs" macro is deprecated because the layout building logic has been revamped for the "detail" page. Check EasyAdmin\'s `detail.html.page` for more details.' %}
  230.     <div class="col-12">
  231.         <div class="nav-tabs-custom form-tabs">
  232.             <ul class="nav nav-tabs">
  233.                 {% for tab in field_layout.tabs %}
  234.                     <li class="nav-item">
  235.                         <a class="nav-link {% if loop.first %}active{% endif %}" href="#tab-pane-{{ tab.uniqueId }}" id="tab-{{ tab.uniqueId }}" data-bs-toggle="tab">
  236.                             {%- if tab.customOption('icon') -%}
  237.                                 <i class="fa-fw {{ tab.customOption('icon') }}"></i>
  238.                             {%- endif -%}
  239.                             {{ tab.label|trans(domain = ea.i18n.translationDomain)|raw }}
  240.                         </a>
  241.                     </li>
  242.                 {% endfor %}
  243.             </ul>
  244.             <div class="tab-content">
  245.                 {% for tab in field_layout.tabs %}
  246.                     <div id="tab-pane-{{ tab.uniqueId }}" class="tab-pane {% if loop.first %}active{% endif %} {{ tab.cssClass|default('') }}">
  247.                         {% if tab.help|default(false) %}
  248.                             <div class="content-header-help tab-help">
  249.                                 {{ tab.help|trans(domain = ea.i18n.translationDomain)|raw }}
  250.                             </div>
  251.                         {% endif %}
  252.                         <div class="row">
  253.                             {{ _self.render_detail_fields(entity, field_layout.fieldsInTab(tab.uniqueId)) }}
  254.                         </div>
  255.                     </div>
  256.                 {% endfor %}
  257.             </div>
  258.         </div>
  259.     </div>
  260. {% endmacro %}
  261. {% macro render_detail_fields(entity, fields) %}
  262.     {% deprecated 'The "render_detail_fields" macro is deprecated because the layout building logic has been revamped for the "detail" page. Check EasyAdmin\'s `detail.html.page` for more details.' %}
  263.     {% set form_fieldset_is_already_open = false %}
  264.     {% for field in fields %}
  265.         {% set is_form_fieldset = 'field-form_fieldset' in field.cssClass %}
  266.         {% if is_form_fieldset or (loop.first and not is_form_fieldset) %}
  267.             {% if form_fieldset_is_already_open %}
  268.                 {{ _self.close_form_fieldset() }}
  269.                 {% set form_fieldset_is_already_open = false %}
  270.             {% endif %}
  271.             {{ _self.open_form_fieldset(is_form_fieldset ? field : null) }}
  272.             {% set form_fieldset_is_already_open = true %}
  273.         {% endif %}
  274.         {% block detail_field %}
  275.             {% if not is_form_fieldset %}
  276.                 {{ _self.render_field(entity, field) }}
  277.             {% endif %}
  278.         {% endblock %}
  279.     {% endfor %}
  280.     {% if form_fieldset_is_already_open %}
  281.         {{ _self.close_form_fieldset() }}
  282.         {% set form_fieldset_is_already_open = false %}
  283.     {% endif %}
  284. {% endmacro %}
  285. {% macro open_form_fieldset(field = null) %}
  286.     {% deprecated 'The "open_form_fieldset" macro is deprecated because the layout building logic has been revamped for the "detail" page. Check EasyAdmin\'s `detail.html.page` for more details.' %}
  287.     {% set fieldset_name = field is null ? null : 'content-' ~ field.uniqueId %}
  288.     {% set collapsible = field is null ? false : field.customOption('collapsible') %}
  289.     {% set collapsed = field is null ? false : field.customOption('collapsed') %}
  290.     {% set fieldset_icon = field is null ? null : (field.customOptions.get('icon')|default(false)) %}
  291.     {% set fieldset_label = field is null ? null : field.label %}
  292.     {% set fieldset_help = field is null ? null : field.help|default(false)%}
  293.     {% set fieldset_has_header = collapsible or fieldset_icon or fieldset_label or fieldset_help %}
  294.     <div class="{{ field.cssClass ?? '' }}">
  295.         <div class="form-fieldset">
  296.             {% if fieldset_has_header %}
  297.                 <div class="form-fieldset-header {{ collapsible ? 'collapsible' }} {{ fieldset_help is not empty ? 'with-help' }}">
  298.                     <div class="form-fieldset-title">
  299.                         <a {% if not collapsible %}
  300.                             href="#" class="not-collapsible"
  301.                         {% else %}
  302.                             href="#{{ fieldset_name }}" data-bs-toggle="collapse"
  303.                             class="form-fieldset-collapse {{ collapsed ? 'collapsed' }}"
  304.                             aria-expanded="{{ collapsed ? 'false' : 'true' }}" aria-controls="{{ fieldset_name }}"
  305.                         {% endif %}
  306.                         >
  307.                             {% if collapsible %}
  308.                                 <i class="fas fw fa-chevron-right form-fieldset-collapse-marker"></i>
  309.                             {% endif %}
  310.                             {% if fieldset_icon %}
  311.                                 <i class="form-fieldset-icon {{ fieldset_icon }}"></i>
  312.                             {% endif %}
  313.                             {{ fieldset_label|trans|raw }}
  314.                         </a>
  315.                         {% if fieldset_help %}
  316.                             <div class="form-fieldset-help">{{ fieldset_help|trans|raw }}</div>
  317.                         {% endif %}
  318.                     </div>
  319.                 </div>
  320.             {% endif %}
  321.             <div {% if fieldset_name %}id="{{ fieldset_name }}"{% endif %} class="form-fieldset-body {{ collapsible ? 'collapse' }} {{ not collapsed ? 'show'}}">
  322.                 <dl class="datalist">
  323. {% endmacro %}
  324. {% macro close_form_fieldset() %}
  325.     {% deprecated 'The "close_form_fieldset" macro is deprecated because the layout building logic has been revamped for the "detail" page. Check EasyAdmin\'s `detail.html.page` for more details.' %}
  326.             </dl>
  327.         </div>
  328.     </div>
  329. </div>
  330. {% endmacro %}
  331. {% macro render_field(entity, field) %}
  332.     {% deprecated 'The "render_field" macro is deprecated because the layout building logic has been revamped for the "detail" page. Check EasyAdmin\'s `detail.html.page` for more details.' %}
  333.     <div class="data-row {{ field.cssClass }}">
  334.         <dt>
  335.             {{ field.label|trans|raw }}
  336.             {% if field.help is not empty %}
  337.                 <a tabindex="0" class="data-help" data-bs-toggle="popover" data-bs-custom-class="ea-content-help-popover" data-bs-animation="true" data-bs-html="true" data-bs-placement="right" data-bs-trigger="focus" data-bs-content="{{ field.help|trans|e('html_attr') }}">
  338.                     <i class="far fa-question-circle"></i>
  339.                 </a>
  340.             {% endif %}
  341.         </dt>
  342.         <dd>
  343.             {{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }}
  344.         </dd>
  345.     </div>
  346. {% endmacro %}