Skip to content

Commit efcb6b5

Browse files
committed
[Docs] Action templates
1 parent 77a7152 commit efcb6b5

1 file changed

Lines changed: 40 additions & 5 deletions

File tree

docs/grid/actions.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ final class SpeakerGrid extends AbstractGrid
5555
->addActionGroup(
5656
MainActionGroup::create(
5757
// Add the "create" action into the "main" action group
58-
CreateAction::create(),
58+
CreateAction::create()
59+
// Optional, you can configure this globally instead.
60+
->setTemplate('path/to/your/action/template.html.twig')
61+
,
5962
),
6063
)
6164
;
@@ -91,7 +94,10 @@ final class SpeakerGrid extends AbstractGrid
9194
->addActionGroup(
9295
ItemActionGroup::create(
9396
// Add the "update" action into the "item" action group
94-
UpdateAction::create(),
97+
UpdateAction::create()
98+
// Optional, you can configure this globally instead.
99+
->setTemplate('path/to/your/action/template.html.twig')
100+
,
95101
),
96102
)
97103
;
@@ -128,13 +134,19 @@ final class SpeakerGrid extends AbstractGrid
128134
->addActionGroup(
129135
ItemActionGroup::create(
130136
// Add the "delete" action into the "item" action group
131-
DeleteAction::create(),
137+
DeleteAction::create()
138+
// Optional, you can configure this globally instead.
139+
->setTemplate('path/to/your/action/template.html.twig')
140+
,
132141
),
133142
)
134143
->addActionGroup(
135144
BulkActionGroup::create(
136145
// Add the "delete" action into the "bulk" action group
137-
DeleteAction::create(),
146+
DeleteAction::create()
147+
// Optional, you can configure this globally instead.
148+
->setTemplate('path/to/your/action/template.html.twig')
149+
,
138150
),
139151
)
140152
;
@@ -170,14 +182,37 @@ final class SpeakerGrid extends AbstractGrid
170182
->addActionGroup(
171183
ItemActionGroup::create(
172184
// Add the "show" action into the "item" action group
173-
ShowAction::create(),
185+
ShowAction::create()
186+
// Optional, you can configure this globally instead.
187+
->setTemplate('path/to/your/action/template.html.twig')
188+
,
174189
),
175190
)
176191
;
177192
}
178193
}
179194
```
180195

196+
## Configuring your action templates globally
197+
198+
```yaml
199+
sylius_grid:
200+
templates:
201+
action:
202+
create: path/to/your/create.html.twig
203+
delete: path/to/your/delete.html.twig
204+
show: path/to/your/show.html.twig
205+
update: path/to/your/update.html.twig
206+
bulk_action:
207+
delete: path/to/your/delete.html.twig
208+
```
209+
210+
{% hint style="info" %}
211+
The BootstrapAdminUi package will configure that for you automatically.
212+
213+
https://github.com/Sylius/Stack/blob/main/src/BootstrapAdminUi/config/app/grid/templates.php
214+
{% endhint %}
215+
181216
## Creating a custom Action
182217
183218
There are certain cases when built-in action types are not enough.

0 commit comments

Comments
 (0)