You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/03-Customization/09-Actions.md
+56-5Lines changed: 56 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -298,13 +298,13 @@ The file points to your SFC in the custom folder (alias `@@/`), and `meta` lets
298
298
```
299
299
300
300
Use this minimal wrapper component to add a border/rounding around the default action UI while keeping the action logic intact.
301
-
Keep the `<slot />` (that's where AdminForth renders the default button) and emit `callAction` to trigger the handler when the wrapper is clicked.
301
+
Keep the `<slot />` (that's where AdminForth renders the default button) and emit `callAction`(optionally with a payload) to trigger the handler when the wrapper is clicked.
You can pass arbitrary data from your custom UI wrapper to the backend action by emitting `callAction` with a payload. That payload will be available on the server under the `extra` argument of your action handler.
330
+
331
+
Frontend examples:
332
+
333
+
```vue title="./custom/ActionBorder.vue"
334
+
<template>
335
+
<!-- Two buttons that pass different flags to the action -->
336
+
<button @click="emit('callAction', { asListed: true })" class="mr-2">Mark as listed</button>
337
+
<button @click="emit('callAction', { asListed: false })">Mark as unlisted</button>
338
+
339
+
<!-- Or keep the default slot button and wrap it: -->
- If you don’t emit a payload, the default behavior is used by the UI (e.g., in lists the current row context is used). When you do provide a payload, it will be forwarded to the backend as `extra` for your action handler.
376
+
- You can combine default context with your own payload by merging before emitting, for example: `emit('callAction', { ...row, asListed: true })` if your component has access to the row object.
0 commit comments