From 50b2d7fc798aeea15e3e6f1883e1d5070d64f35a Mon Sep 17 00:00:00 2001 From: Meindert Date: Mon, 19 Oct 2026 10:00:41 +0200 Subject: [PATCH 1/2] Document relation toolbar button permissions Co-Authored-By: Claude Opus 5.5 --- backend/relations.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/backend/relations.md b/backend/relations.md index 4c744831..048b51b7 100644 --- a/backend/relations.md +++ b/backend/relations.md @@ -77,6 +77,28 @@ items: recordsPerPage: 10 ``` +A button can also be defined as an array with an optional `label` and `permissions`. The [permissions](users#users-and-permissions) work the same as for [form fields](forms#field-options): only one of them is needed to grant access. A button the user has no access to is hidden, and the AJAX handlers that perform its action abort with a 403 error. + +```yaml +items: + label: Invoice Line Item + view: + list: $/acme/pay/models/invoiceitem/columns.yaml + toolbarButtons: + create: Add a line item + delete: + label: Remove line item + permissions: [acme.pay.delete_invoice_items] +``` + +Button | Protected handlers +------------- | ------------- +`create` | `onRelationManageCreate` +`update` | `onRelationManageUpdate` +`delete` | `onRelationManageDelete` +`add`, `link` | `onRelationManageAdd`, `onRelationManagePivotCreate` +`remove`, `unlink` | `onRelationManageRemove` + The following options are then used for each relationship name definition: Option | Description @@ -116,7 +138,7 @@ Option | Type | Description `recordOnClick` | List | custom JavaScript code to execute when clicking on a record. `sortable` | List | enables drag-and-drop reordering of the related records, see [reordering relations](#reordering-relations). Requires the parent model to use the [`HasSortableRelations` trait](../database/traits#hassortablerelations). Default: `false`. `toolbarPartial` | Both | a reference to a controller partial file with the toolbar buttons. Eg: **_relation_toolbar.htm**. This option overrides the *toolbarButtons* option. -`toolbarButtons` | Both | the set of buttons to display. This can be formatted as an array or a pipe separated string, or set to `false` to show no buttons. Available options are: `create`, `update`, `delete`, `add`, `remove`, `refresh`, `link`, & `unlink`. Example: `add\|remove`.
Additionally, you can customize the text inside these buttons by setting this property to an associative array, with the key being the button type and the value being the text for that button. Example: `create: 'Assign User'`. The value also supports translation. +`toolbarButtons` | Both | the set of buttons to display. This can be formatted as an array or a pipe separated string, or set to `false` to show no buttons. Available options are: `create`, `update`, `delete`, `add`, `remove`, `refresh`, `link`, & `unlink`. Example: `add\|remove`.
Additionally, you can customize the text inside these buttons by setting this property to an associative array, with the key being the button type and the value being the text for that button. Example: `create: 'Assign User'`. The value also supports translation. Each button can also be restricted with `permissions`, see [above](#configuring-the-relation-behavior). These configuration values can be specified only for the **manage** options. From e227e234cbe7c21d4449392e9600c5b21e7e3dc1 Mon Sep 17 00:00:00 2001 From: Meindert Date: Mon, 19 Oct 2026 15:45:46 +0200 Subject: [PATCH 2/2] Split add/link and remove/unlink in the protected handlers table Each handler only checks the button of its own view mode. Co-Authored-By: Claude Opus 5.5 --- backend/relations.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/relations.md b/backend/relations.md index 048b51b7..dc844c95 100644 --- a/backend/relations.md +++ b/backend/relations.md @@ -96,8 +96,10 @@ Button | Protected handlers `create` | `onRelationManageCreate` `update` | `onRelationManageUpdate` `delete` | `onRelationManageDelete` -`add`, `link` | `onRelationManageAdd`, `onRelationManagePivotCreate` -`remove`, `unlink` | `onRelationManageRemove` +`add` | `onRelationManageAdd` (multi), `onRelationManagePivotCreate` +`link` | `onRelationManageAdd` (single) +`remove` | `onRelationManageRemove` (multi) +`unlink` | `onRelationManageRemove` (single) The following options are then used for each relationship name definition: