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: backend/forms.md
+70
Original file line number
Diff line number
Diff line change
@@ -303,6 +303,76 @@ gender:
303
303
304
304
See [Defining field options](#defining-field-options) for the different methods to specify the options.
305
305
306
+
### Button
307
+
308
+
`button`- renders a single [button](../../ui/controls/button). Supports triggering an [AJAX request](../ajax/introduction), acting as a link to a URL, or [opening a popup](../../ui/controls/popup#remote-popups).
309
+
310
+
The `action` of the button (`button`, `link`, or `popup`) is determined by the configuration of the button. If the value of the field is a valid URL, or the `href` property is set, then it will be a `link` action. If a `handler` property is set, it will be a `popup` action. All other cases will result in the `button` action.
311
+
312
+
```yaml
313
+
button:
314
+
type: button
315
+
buttonLabel: # The label of the button itself.
316
+
buttonType: # default | primary | success | info | warning | danger | link
317
+
path: # Use a custom partial to render the button
318
+
handler: # popup action only
319
+
href: # link action only
320
+
target: # link action only
321
+
request: # button action only
322
+
loading: # message to display while waiting for the request
323
+
icon: 'icon-pencil'
324
+
```
325
+
326
+
The partial used to render the partial can be manually specified by providing the `path` property, the same as a [`partial`](#partial) field. This partial will receive the same variables as a regular `partial` field, with the addition of the following variables:
327
+
328
+
Variable | Description
329
+
------------- | -------------
330
+
`$action`| The action of the button. One of `button`, `link`, `popup`.
331
+
`$element`| The HTML element recommended to use for the button. Either `a` or `button`.
332
+
`$label`| The label of the button itself.
333
+
`$buttonType`| The type of button to render. One of `default`, `primary`, `success`, `info`, `warning`, `danger`, `link`.
334
+
`$classes`| The CSS classes that should be applied to the button element.
335
+
`$handler`| The popup AJAX handler.
336
+
`$request`| The AJAX request to send when the button is clicked.
337
+
`$href`| The URL to link to for a `link` action button.
338
+
`$target`| The `target` attribute for the `link` action button.
339
+
`$loading`| The loading message to display when the button has been clicked. Populates the `data-load-indicator` attribute on the button element.
340
+
`$icon`| The [icon class](../../ui/style/icon) to use for the icon element inside the button.
0 commit comments