Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions gp-advanced-select/gpadvs-clear-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Gravity Perks // Advanced Select // Clear Button
* https://gravitywiz.com/documentation/gravity-forms-advanced-select/
*
* Adds a Clear buton to GP Advanced 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) {
/**
* Scope to only dropdown fields.
* This can also be changed to 'multiselect' to only target multi-select fields
* OR the conditional can be removed to apply to all fields.
*/
if (gpadvsInstance.fieldType === 'dropdown') {
settings.plugins.clear_button = {
title: 'Clear options',
};
}

return settings;
}
);
26 changes: 26 additions & 0 deletions gp-advanced-select/gpadvs-dropdown-remove-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Gravity Perks // Advanced Select // Dropdown Remove Button
* https://gravitywiz.com/documentation/gravity-forms-advanced-select/
*
* Adds a Remove button to selection options in Dropdown and MultiSelect fields.
*
* The Remove Button is a built in plugin of Tom Select.
* @reference https://tom-select.js.org/plugins/remove-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.remove_button = {
title: window.GPADVS.strings?.remove_this_item
? window.GPADVS.strings.remove_this_item
: 'Remove this item',
}

return settings;
}
);
Loading