|
| 1 | +{# @see https://symfony.com/bundles/EasyAdminBundle/current/design.html#form-field-templates #} |
| 2 | +{% block _Theme_themeCategories_widget %} |
| 3 | + {% set id = 'form-theme-themeCategories' %} |
| 4 | + <table class="table table-striped" id="{{ id }}"> |
| 5 | + <thead> |
| 6 | + <th>{{ 'theme.form.sort_order'|trans }}</th> |
| 7 | + <th>{{ 'theme.form.category'|trans }}</th> |
| 8 | + <th></th> |
| 9 | + </thead> |
| 10 | + <tbody class="ea-form-collection-items field-array"> |
| 11 | + {{ block('_Theme_themeCategories_collection_widget') }} |
| 12 | + </tbody> |
| 13 | + </table> |
| 14 | + {# Pretend that the collection is an array collection to make "add item" not assume that we have an accordion, cf. vendor/easycorp/easyadmin-bundle/assets/js/field-collection.js #} |
| 15 | + <script> |
| 16 | + const el = document.getElementById({{ id|json_encode|raw }}).closest('[data-ea-collection-field]'); |
| 17 | + if (el) { |
| 18 | + el.classList.add('field-array') |
| 19 | + } |
| 20 | + </script> |
| 21 | + |
| 22 | + {% if allow_add|default(false) and not disabled %} |
| 23 | + <button type="button" class="btn btn-link field-collection-add-button"> |
| 24 | + <twig:ea:Icon name="internal:plus" class="pr-1" /> |
| 25 | + {{ 'theme.form.add_new_item'|trans }} |
| 26 | + </button> |
| 27 | + {% endif %} |
| 28 | +{% endblock %} |
| 29 | + |
| 30 | +{% block _Theme_themeCategories_collection_widget %} |
| 31 | + {% set isEmptyCollection = value is null or (value is iterable and value is empty) %} |
| 32 | + |
| 33 | + {% if isEmptyCollection %} |
| 34 | + {{ block('_Theme_themeCategories_empty_collection') }} |
| 35 | + {% else %} |
| 36 | + {{ block('form_widget') }} |
| 37 | + {% endif %} |
| 38 | +{% endblock %} |
| 39 | + |
| 40 | +{% block _Theme_themeCategories_empty_collection %} |
| 41 | + <tr> |
| 42 | + <td colspan="3"> |
| 43 | + {{ 'No theme categories'|trans }} |
| 44 | + </td> |
| 45 | + </tr> |
| 46 | +{% endblock %} |
| 47 | + |
| 48 | +{% block _Theme_themeCategories_entry_row %} |
| 49 | + {# See block collection_entry_row in @EasyAdmin:crud/form_theme.html.twig for details on which bits and pieces are used to stitch this together #} |
| 50 | + <tr class="field-collection-item"> |
| 51 | + <td> |
| 52 | + {{ form_widget(form.sortOrder) }} |
| 53 | + {{ form_errors(form.sortOrder) }} |
| 54 | + </td> |
| 55 | + <td> |
| 56 | + {{ form_widget(form.category) }} |
| 57 | + {{ form_errors(form.category) }} |
| 58 | + </td> |
| 59 | + <td> |
| 60 | + <button type="button" class="btn btn-danger field-collection-delete-button"> |
| 61 | + {{ 'theme.form.delete_item'|trans }} |
| 62 | + </button> |
| 63 | + </td> |
| 64 | + </tr> |
| 65 | +{% endblock %} |
0 commit comments