Skip to content

Commit

Permalink
gw-capitilize-submitted-data.php: Added support to capitalize list …
Browse files Browse the repository at this point in the history
…fields.
  • Loading branch information
saifsultanc authored Oct 31, 2024
1 parent 9359c60 commit 6762bc1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gravity-forms/gw-capitilize-submitted-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
add_action( 'gform_pre_submission_123', 'gw_capitalize_submitted_data' );
function gw_capitalize_submitted_data( $form ) {

$applicable_input_types = array( 'address', 'text', 'textarea', 'name' );
$applicable_input_types = array( 'address', 'text', 'textarea', 'name', 'list' );

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

Expand All @@ -27,8 +27,14 @@ function gw_capitalize_submitted_data( $form ) {
$_POST[ $input_key ] = ucwords( strtolower( rgpost( $input_key ) ) );
}
} else {
$input_key = sprintf( 'input_%s', $field['id'] );
$_POST[ $input_key ] = ucwords( strtolower( rgpost( $input_key ) ) );
$input_key = sprintf( 'input_%s', $field['id'] );
if ( $field->type == 'list' ) {
$_POST[ $input_key ] = array_map( function( $value ) {
return ucwords( strtolower( $value ) );
}, $_POST[ $input_key ] );
} else {
$_POST[ $input_key ] = ucwords( strtolower( rgpost( $input_key ) ) );
}
}
}

Expand Down

0 comments on commit 6762bc1

Please sign in to comment.