-
Notifications
You must be signed in to change notification settings - Fork 92
gpadvs-dropdown-remove-button.js: Added snippet to show remove button on Dropdown fields.
#1028
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
Changes from 3 commits
ef7aba0
0de9613
793d79e
8752ed8
148b7c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /** | ||
| * Gravity Perks // Advanced Select // Clear Button | ||
| * https://gravitywiz.com/documentation/gravity-forms-advanced-select/ | ||
| * | ||
| * Adds a Clearn button to selection options in Dropdown fields. By default, | ||
| * the remove button is only added to Multi-Select fields. | ||
| * | ||
| * The Clear Button is a built in plugin of Tom Select. | ||
| * @reference https://tom-select.js.org/plugins/clear-button/ | ||
| * | ||
| * Instructions: | ||
| * | ||
| * 1. Install this snippet with our free Custom JavaScript plugin. | ||
| * https://gravitywiz.com/gravity-forms-code-chest/ | ||
| */ | ||
| window.gform.addFilter( | ||
| 'gpadvs_settings', | ||
| function(settings, gpadvsInstance, selectNamespace) { | ||
| settings.plugins.clear_button = { | ||
| title: 'Clear options', | ||
| }; | ||
|
|
||
| return settings; | ||
| } | ||
| ); | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||
| * Gravity Perks // Advanced Select // Dropdown Remove Button | ||||||||||||||||||||||||||||||||||||||
| * https://gravitywiz.com/documentation/gravity-forms-advanced-select/ | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
| * Adds a Remove button to selection options in Dropdown fields. By default, | ||||||||||||||||||||||||||||||||||||||
| * the remove button is only added to Multi-Select fields. | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
| * Adds a Remove button to selection options in Dropdown fields. By default, | |
| * the remove button is only added to Multi-Select fields. | |
| * | |
| function(settings, gpadvsInstance, selectNamespace) { | |
| /** | |
| * Scope to only multi-select fields. | |
| * This conditional can be modified to target different field types. | |
| */ | |
| if (gpadvsInstance.fieldType === 'multiselect') { | |
| settings.plugins.remove_button = { | |
| title: window.GPADVS.strings?.remove_this_item | |
| ? window.GPADVS.strings.remove_this_item | |
| : 'Remove this item', | |
| } | |
| } | |
| return settings; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, code rabbit :finger-guns. Updated ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@veryspry Thank you for implementing the suggested change! This will ensure the implementation aligns with the documentation and targets only multi-select fields as intended.
(\ /)
(・ᴗ・)
/ >🥕
Uh oh!
There was an error while loading. Please reload this page.