Skip to content

Commit 80dcfef

Browse files
committed
gpadvs-dropdown-remove-button.js: Added snippet to show "Clear" button.
1 parent fe78dcb commit 80dcfef

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Gravity Perks // Advanced Select // Clear Button
3+
* https://gravitywiz.com/documentation/gravity-forms-advanced-select/
4+
*
5+
* Adds a Clearn button to selection options in Dropdown fields. By default,
6+
* the remove button is only added to Multi-Select fields.
7+
*
8+
* The Clear Button is a built in plugin of Tom Select.
9+
* @reference https://tom-select.js.org/plugins/clear-button/
10+
*
11+
* Instructions:
12+
*
13+
* 1. Install this snippet with our free Custom JavaScript plugin.
14+
* https://gravitywiz.com/gravity-forms-code-chest/
15+
*/
16+
17+
function getNestedKey(obj, path) {
18+
for (piece of path) {
19+
if (!obj.hasOwnProperty(piece)) {
20+
return undefined;
21+
}
22+
23+
obj = obj[piece];
24+
}
25+
26+
return obj;
27+
}
28+
29+
window.gform.addFilter(
30+
'gpadvs_settings',
31+
function(settings, gpadvsInstance, selectNamespace) {
32+
settings.plugins.clear_button = {
33+
title: 'Clear options',
34+
};
35+
36+
return settings;
37+
}
38+
);

0 commit comments

Comments
 (0)