Homepage
Main navigation
Main content
Additional information
October Tricks
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
October CMS resources and help articles
Simple and to the point. Optimized by the community.
×
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
Edit trick
Changes will be published after manual review
Title
Give your trick a describing title. Do
not
start with «How to...».
Your trick
Keep it short and concise! Markdown is supported.
Sometimes you may want to add a custom button to a relation widget to execute a custom action or extend the function of the default buttons. You can easily do this by specifying a custom key in the `toolbarButtons` option of your `config_relation.yaml`: ```yaml # =================================== # Relation Behavior Config # =================================== items: label: Invoice Line Item view: list: $/acme/pay/models/invoiceitem/columns.yaml toolbarButtons: create|delete|custom # Add this manage: form: $/acme/pay/models/invoiceitem/fields.yaml recordsPerPage: 10 ``` Next, create a new file `_relation_button_custom.htm` (the last part corresponds to the item in your configuration file) in your controller's partial directory (e. g. `/plugins/acme/controllers/invoices/`) with the following contents: ``` <button class="btn btn-sm btn-secondary" data-request="onDoSomething" data-stripe-load-indicator> Custom </button> ``` In this case, the button will just call the handler `onDoSomething` of your controller. But you can also go more advanced and pass the selected (checked) items or any custom variables to the controller. You can even open a custom modal and render complex controls. A lot of the markup can be reused from the [existing button partials](https://github.com/octobercms/october/tree/master/modules/backend/behaviors/relationcontroller/partials).
References
Add additional online resources to your trick
×
Name
URL
×
Name
URL
+ Add reference
Topics
If your trick fits more than one topic select multiple. Select at least one.
Backend
Plugin Development
CMS
Twig
Themes
Deployment
Tags
You can use existing tags or create new ones. Add at least one.
Submit for review
Cancel
We use cookies to measure the performance of this website. Do you want to accept these cookies?
Accept
Decline