Skip to content

Commit fd6db30

Browse files
committed
Fix data table template when no grid is attached to the index operation
1 parent 5e656aa commit fd6db30

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

app/Entity/Book.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
new Create(),
3737
new Update(),
3838
new Index(grid: BookGrid::class),
39+
new Index(
40+
template: '@SyliusAdminUi/crud/index.html.twig',
41+
shortName: 'withoutGrid',
42+
),
3943
new Delete(),
4044
new BulkDelete(),
4145
new Show(),

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"phpstan/phpstan": "^1.10",
5050
"phpstan/phpstan-symfony": "^1.3",
5151
"phpunit/phpunit": "^9.6",
52+
"slevomat/coding-standard": "<8.23",
5253
"sylius-labs/coding-standard": "^4.0",
5354
"symfony/browser-kit": "^6.4 || ^7.0",
5455
"symfony/console": "^6.4 || ^7.0",

src/BootstrapAdminUi/templates/shared/crud/index/content/grid/data_table.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{% import '@SyliusBootstrapAdminUi/shared/helper/pagination.html.twig' as pagination %}
33

44
{% set resources = hookable_metadata.context.resources %}
5-
{% set data = resources.data %}
6-
{% set definition = resources.definition %}
5+
{% set data = resources.data|default([]) %}
6+
{% set definition = resources.definition|default(null) %}
77

88
{% if data|length > 0 %}
99
<div class="card">

src/BootstrapAdminUi/templates/shared/crud/index/content/grid/filters.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{% set path = path(app.request.attributes.get('_route'), app.request.attributes.all('_route_params')) %}
77
{% set are_criteria_set = app.request.query.has('criteria') %}
88

9-
{% if resources.definition.enabledFilters is not empty %}
9+
{% if resources.definition.enabledFilters|default([]) is not empty %}
1010
<div class="position-relative z-1 bg-white mb-5">
1111
{% set content %}
1212
<div class="mb-3">

src/BootstrapAdminUi/templates/shared/crud/index/content/grid/no_results.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% set resources = hookable_metadata.context.resources %}
22

3-
{% if resources.data|length == 0 %}
3+
{% if resources.data is defined and resources.data|length == 0 %}
44
<div class="card">
55
<div class="empty">
66
{% hook 'no_results' %}

0 commit comments

Comments
 (0)