Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add button field #1324

Merged
merged 2 commits into from
Mar 5, 2025
Merged

Add button field #1324

merged 2 commits into from
Mar 5, 2025

Conversation

LukeTowers
Copy link
Member

Adds support for the type: button field with the following options:

Definition

button:
    type: button
    action: # button | link | popup (automatically determined by the values provider, if the value of the field is a URL or the href config is set (or the value of the field is a valid URL), then it'll be type link. If a handler is set, it'll be type popup. All other cases will be type: button)
    buttonLabel: # The label of the button itself.
    buttonType: # default | primary | success | info | warning | danger | link
    path: # Use a custom partial to render the button
    handler: # popup action only
    href: # link action only
    target: # link action only
    request: # button action only
    loading: # message to display while waiting for the request
    icon: 'icon-pencil'

Examples:

Simple button with AJAX request:

_sync_ics:
    label: Actions
    buttonLabel: Sync
    type: button
    request: onSyncICS
    icon: 'icon-rotate'
    loading: Syncing...

Simple Link button:

places_url:
    type: button
    buttonType: primary
    buttonLabel: View on Google Maps
    icon: icon-map-location-dot
    target: _blank

Button triggering popup:

_btn_autofill:
    label: Autofill
    buttonLabel: Autofill Club Information
    type: button
    handler: onRenderAutofillPopup
    buttonType: primary
    icon: icon-map-location-dot

Adds support for the `type: button` field with the following options:

```yaml
button:
    type: button
    action: # button | link | popup (automatically determined by the values provider, if the value of the field is a URL or the href config is set (or the value of the field is a valid URL), then it'll be type link. If a handler is set, it'll be type popup. All other cases will be type: button)
    buttonLabel: # The label of the button itself.
    buttonType: # default | primary | success | info | warning | danger | link
    path: # Use a custom partial to render the button
    handler: # popup action only
    href: # link action only
    target: # link action only
    request: # button action only
    loading: # message to display while waiting for the request
    icon: 'icon-pencil'
```

Examples:

Simple button with AJAX request:
```yaml
_sync_ics:
    label: Actions
    buttonLabel: Sync
    type: button
    request: onSyncICS
    icon: 'icon-rotate'
    loading: Syncing...
```

Simple Link button:
```yaml
places_url:
    type: button
    buttonType: primary
    buttonLabel: View on Google Maps
    icon: icon-map-location-dot
    target: _blank
```

Button triggering popup:
```yaml
_btn_autofill:
    label: Autofill
    buttonLabel: Autofill Club Information
    type: button
    handler: onRenderAutofillPopup
    buttonType: primary
    icon: icon-map-location-dot
```
@LukeTowers LukeTowers added the enhancement PRs that implement a new feature or substantial change label Mar 5, 2025
@LukeTowers LukeTowers added this to the 1.2.8 milestone Mar 5, 2025
Copy link
Member

@jaxwilko jaxwilko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

LukeTowers added a commit to wintercms/docs that referenced this pull request Mar 5, 2025
@LukeTowers LukeTowers merged commit 6f56935 into develop Mar 5, 2025
13 checks passed
@LukeTowers LukeTowers deleted the feature/button-field branch March 5, 2025 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement PRs that implement a new feature or substantial change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants