Skip to content

Commit d1f7e05

Browse files
authored
gfcs-auto-chained-select.php: Migrated. (#930)
* `gfcs-auto-chained-select.php`: Migrated. * Update gfcs-auto-chained-select.php
1 parent 87394fc commit d1f7e05

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed
Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
11
<?php
22
/**
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.
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/gravity-forms/gfcs-auto-chained-select.php.php
96
*/
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)