templates/bundles/EasyAdminBundle/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. {% trans_default_domain ea.i18n.translationDomain %}
  5. {% block body_id 'ea-detail-' ~ entity.name ~ '-' ~ entity.primaryKeyValue %}
  6. {% block body_class 'ea-detail ea-detail-' ~ entity.name %}
  7. {% block content_title %}
  8.     {%- apply spaceless -%}
  9.         {% set custom_page_title = ea.crud.customPageTitle(pageName, entity ? entity.instance : null) %}
  10.         {{ custom_page_title is null
  11.             ? (ea.crud.defaultPageTitle|trans(ea.i18n.translationParameters, 'EasyAdminBundle'))|raw
  12.             : (custom_page_title|trans(ea.i18n.translationParameters))|raw }}
  13.     {%- endapply -%}
  14. {% endblock %}
  15. {% block page_actions %}
  16.     {% for action in entity.actions %}
  17.         {{ include(action.templatePath, { action: action }, with_context = false) }}
  18.     {% endfor %}
  19. {% endblock %}
  20. {% block content_footer_wrapper '' %}
  21. {% block main %}
  22.     {% block detail_fields %}
  23.         {% set form_panel_is_already_open = false %}
  24.         {% for field in entity.fields %}
  25.             {% set is_form_field_panel = 'field-form_panel' in field.cssClass %}
  26.             {% if is_form_field_panel or (loop.first and not is_form_field_panel) %}
  27.                 {% if form_panel_is_already_open %}
  28.                     {{ _self.close_form_field_panel() }}
  29.                     {% set form_panel_is_already_open = false %}
  30.                 {% endif %}
  31.                 {{ _self.open_form_field_panel(is_form_field_panel ? field : null) }}
  32.                 {% set form_panel_is_already_open = true %}
  33.             {% endif %}
  34.             {% block detail_field %}
  35.                 {% if not is_form_field_panel %}
  36.                     {{ _self.render_field(entity, field) }}
  37.                 {% endif %}
  38.             {% endblock %}
  39.         {% endfor %}
  40.         {{ _self.close_form_field_panel() }}
  41.     {% endblock %}
  42.     {% block delete_form %}
  43.         {{ include('@EasyAdmin/crud/includes/_delete_form.html.twig', { entity_id: entity.primaryKeyValue }, with_context = false) }}
  44.     {% endblock delete_form %}
  45. {% endblock %}
  46. {% macro open_form_field_panel(field = null) %}
  47.     {% set panel_name = field is null ? null : 'content-' ~ field.uniqueId %}
  48.     {% set collapsible = field is null ? false : field.customOption('collapsible') %}
  49.     {% set collapsed = field is null ? false : field.customOption('collapsed') %}
  50.     {% set panel_icon = field is null ? null : (field.customOptions.get('icon')|default(false)) %}
  51.     {% set panel_label = field is null ? null : field.label %}
  52.     {% set panel_help = field is null ? null : field.help|default(false)%}
  53.     {% set panel_has_header = collapsible or panel_icon or panel_label or panel_help %}
  54.     <div class="{{ field.cssClass ?? '' }}">
  55.         <div class="form-panel">
  56.             {% if panel_has_header %}
  57.                 <div class="form-panel-header {{ collapsible ? 'collapsible' }} {{ panel_help is not empty ? 'with-help' }}">
  58.                     <div class="form-panel-title">
  59.                         <a {% if not collapsible %}
  60.                             href="#" class="not-collapsible"
  61.                         {% else %}
  62.                             href="#{{ panel_name }}" data-bs-toggle="collapse"
  63.                             class="form-panel-collapse {{ collapsed ? 'collapsed' }}"
  64.                             aria-expanded="{{ collapsed ? 'false' : 'true' }}" aria-controls="{{ panel_name }}"
  65.                         {% endif %}
  66.                         >
  67.                             {% if collapsible %}
  68.                                 <i class="fas fw fa-chevron-right form-panel-collapse-marker"></i>
  69.                             {% endif %}
  70.                             {% if panel_icon %}
  71.                                 <i class="form-panel-icon {{ panel_icon }}"></i>
  72.                             {% endif %}
  73.                             {{ panel_label|raw }}
  74.                         </a>
  75.                         {% if panel_help %}
  76.                             <div class="form-panel-help">{{ panel_help|raw }}</div>
  77.                         {% endif %}
  78.                     </div>
  79.                 </div>
  80.             {% endif %}
  81.             <div {% if panel_name %}id="{{ panel_name }}"{% endif %} class="form-panel-body {{ collapsible ? 'collapse' }} {{ not collapsed ? 'show'}}">
  82.                 <dl class="datalist">
  83. {% endmacro %}
  84. {% macro close_form_field_panel() %}
  85.             </dl>
  86.         </div>
  87.     </div>
  88. </div>
  89. {% endmacro %}
  90. {% macro render_field(entity, field) %}
  91.     <div class="data-row {{ field.cssClass }}">
  92.         <dt>
  93.             {{ field.label|raw }}
  94.             {% if field.help is not empty %}
  95.                 <span class="data-help">
  96.                     <i class="far fa-question-circle" data-bs-toggle="tooltip" title="{{ field.help|e('html_attr') }}"></i>
  97.                 </span>
  98.             {% endif %}
  99.         </dt>
  100.         <dd>
  101.             {{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }}
  102.         </dd>
  103.     </div>
  104. {% endmacro %}