Skip to content

Commit e694a02

Browse files
authored
gfcs-auto-chained-select.php: Migrated.
1 parent 87394fc commit e694a02

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed
Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,5 @@
1-
<?php
21
/**
3-
* Gravity Wiz // Gravity Forms Chained Selects // Auto Select Only Option
4-
* https://gravitywiz.com/
5-
*
6-
* The Gravity Forms Chained Selects field requires you to manually select a value in each Drop Down
7-
* even if there is only a single option available in that Drop Down. This snippet will automatically
8-
* selected an option when it is the only option available.
2+
* We're no longer using the experimental folder for experimental snippets. 🚧
3+
* You can now find the snippet here:
4+
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gfcs-auto-chained-select.php.php
95
*/
10-
add_filter( 'gform_chained_selects_input_choices', function( $choices ) {
11-
$choices = gfcs_auto_select_only_choice( $choices );
12-
return $choices;
13-
} );
14-
15-
function gfcs_auto_select_only_choice( $choices ) {
16-
17-
$choices[0]['isSelected'] = $choices[0]['isSelected'] || count( $choices ) <= 1;
18-
19-
if ( ! empty( $choices['choices'] ) ) {
20-
$choices['choices'] = gfcs_auto_select_only_choice( $choices['choices'] );
21-
}
22-
23-
return $choices;
24-
}

0 commit comments

Comments
 (0)