Skip to content

Commit 8752ed8

Browse files
committed
gpadvs-dropdown-remove-button.js: Added conditional showing how to scope to _only_ dropdown or multiselect fields.
1 parent 793d79e commit 8752ed8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

gp-advanced-select/gpadvs-clear-button.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
* Gravity Perks // Advanced Select // Clear Button
33
* https://gravitywiz.com/documentation/gravity-forms-advanced-select/
44
*
5-
* Adds a Clearn button to selection options in Dropdown fields. By default,
6-
* the remove button is only added to Multi-Select fields.
5+
* Adds a Clear buton to GP Advanced Select fields.
76
*
87
* The Clear Button is a built in plugin of Tom Select.
98
* @reference https://tom-select.js.org/plugins/clear-button/
@@ -16,9 +15,16 @@
1615
window.gform.addFilter(
1716
'gpadvs_settings',
1817
function(settings, gpadvsInstance, selectNamespace) {
19-
settings.plugins.clear_button = {
20-
title: 'Clear options',
21-
};
18+
/**
19+
* Scope to only dropdown fields.
20+
* This can also be changed to 'multiselect' to only target multi-select fields
21+
* OR the conditional can be removed to apply to all fields.
22+
*/
23+
if (gpadvsInstance.fieldType === 'dropdown') {
24+
settings.plugins.clear_button = {
25+
title: 'Clear options',
26+
};
27+
}
2228

2329
return settings;
2430
}

0 commit comments

Comments
 (0)