Skip to content

Commit 4c048a1

Browse files
authored
gpeb-use-select-for-country-filter.php: Migrated.
1 parent e21b59b commit 4c048a1

File tree

1 file changed

+3
-47
lines changed

1 file changed

+3
-47
lines changed
Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,6 @@
11
<?php
22
/**
3-
* Gravity Perks // Entry Blocks // Filters Block: Use Select for Country Input Filter
4-
* https://gravitywiz.com/documentation/gravity-forms-entry-blocks/
5-
*
6-
* All input fields in the Entry Blocks filter are text inputs by default. This snippet changes the input type to a
7-
* select for the Address field's Country input.
3+
* We're no longer using the experimental folder for experimental snippets. 🚧
4+
* You can now find the snippet here:
5+
* https://github.com/gravitywiz/snippet-library/blob/master/gp-entry-blocks/gpeb-use-select-for-country-filter.php
86
*/
9-
add_filter( 'gpeb_filter_form_field', function ( $field ) {
10-
if ( ! rgar( $field, 'gpebFilterInputField' ) ) {
11-
return $field;
12-
}
13-
14-
$input_field = $field['gpebFilterInputField'];
15-
16-
// If we're not working with an Address field, return the field as-is.
17-
if ( $input_field['type'] !== 'address' ) {
18-
return $field;
19-
}
20-
21-
// Get the input ID.
22-
$input_id = explode( '.', rgar( $field, 'gpebFilterSearch' ) )[1];
23-
24-
switch ( $input_id ) {
25-
// Country
26-
case 6:
27-
$country_choices = array_map( function ( $country ) {
28-
return array(
29-
'text' => $country,
30-
'value' => $country,
31-
);
32-
}, $field['gpebFilterInputField']->get_countries() );
33-
34-
// Change the field to a select and populate it with countries from the address field.
35-
$new_field = new \GF_Field_Select( array(
36-
'id' => $field['id'],
37-
'label' => $field['label'],
38-
'gpebFilterSearch' => $field['gpebFilterSearch'],
39-
'gpebFilterInputField' => $field['gpebFilterInputField'],
40-
'size' => $field['size'],
41-
'inputs' => $field['inputs'],
42-
'formId' => $field['formId'],
43-
'type' => 'select',
44-
'choices' => $country_choices,
45-
) );
46-
return $new_field;
47-
}
48-
49-
return $field;
50-
} );

0 commit comments

Comments
 (0)