Skip to content

Commit 6762bc1

Browse files
authored
gw-capitilize-submitted-data.php: Added support to capitalize list fields.
1 parent 9359c60 commit 6762bc1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

gravity-forms/gw-capitilize-submitted-data.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
add_action( 'gform_pre_submission_123', 'gw_capitalize_submitted_data' );
1212
function gw_capitalize_submitted_data( $form ) {
1313

14-
$applicable_input_types = array( 'address', 'text', 'textarea', 'name' );
14+
$applicable_input_types = array( 'address', 'text', 'textarea', 'name', 'list' );
1515

1616
foreach ( $form['fields'] as $field ) {
1717

@@ -27,8 +27,14 @@ function gw_capitalize_submitted_data( $form ) {
2727
$_POST[ $input_key ] = ucwords( strtolower( rgpost( $input_key ) ) );
2828
}
2929
} else {
30-
$input_key = sprintf( 'input_%s', $field['id'] );
31-
$_POST[ $input_key ] = ucwords( strtolower( rgpost( $input_key ) ) );
30+
$input_key = sprintf( 'input_%s', $field['id'] );
31+
if ( $field->type == 'list' ) {
32+
$_POST[ $input_key ] = array_map( function( $value ) {
33+
return ucwords( strtolower( $value ) );
34+
}, $_POST[ $input_key ] );
35+
} else {
36+
$_POST[ $input_key ] = ucwords( strtolower( rgpost( $input_key ) ) );
37+
}
3238
}
3339
}
3440

0 commit comments

Comments
 (0)