Skip to content

Commit 4f55cdf

Browse files
authored
gpaa-gf-address-enhanced.js: Migrated from experimental folder.
1 parent a1c7410 commit 4f55cdf

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Gravity Perks // GP Address Autocomplete // Populate State/Province Drop Down for GF Address Enhanced
3+
* https://gravitywiz.com/documentation/gravity-forms-address-autocomplete
4+
*
5+
* Experimental Snippet 🧪
6+
*
7+
* Add support for automatically selecting the state/province when using the Gravity Forms Address Enhanced plugin.
8+
* GF Address Enhanced does not preserve the populated value in the input when the field is converted
9+
* into a select after the country is automatically populated by GPAA.
10+
*
11+
* Instructions:
12+
* 1. Install our free Custom JavaScript for Gravity Forms plugin.
13+
* Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
14+
* 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
15+
*/
16+
gform.addAction('gpaa_fields_filled', function (place, instance, formId, fieldId) {
17+
place.address_components.forEach( function( component ) {
18+
if ( component.types.indexOf( 'administrative_area_level_1' ) !== -1 ) {
19+
// Update "1" to the field ID in which you would GPAA and GF Address Enhanced enabled
20+
$( '#input_GFFORMID_1_4 option[value="' + component.short_name + '"]' ).attr('selected', 'selected');
21+
}
22+
} );
23+
} );

0 commit comments

Comments
 (0)