Uppercase all submitted data

It is possible to uppercase all submitted data? Please help

Hello. Yes, you can do that if you want to. See this example using the gform_save_field_value filter: https://docs.gravityforms.com/gform_save_field_value/#4-uppercase-value

That shows uppercasing all text fields. If you need to apply that to more fields, you can modify this line to include other field types or field IDs:

if ( $field->get_input_type() == 'text' ) {

It does not work in list field. how can i make it work? thanks

I try this for list field but it did not work. Thoughts?

if ( $field->get_input_type() == ‘list’ ) {

Hello, Uppercasing the values form a List field will be more complex, because the data is serialized before storage. You would have to unserialize the data, uppercase the values, then reserialize the data before storage to use the gform_save_field_value filter.

One other possibility if you did not want to go through all that, would be to use the gform_pre_submission filter, if you know the ID of the list field. I came up with something quickly which you could build upon. It works for one list field in a form only (field ID 3 in my example.) There are two places where you need to update the ID from 3 to the ID of your list field. Additionally, change 754 to your form ID.

add_action( 'gform_pre_submission_754', 'pre_submission_handler_754' );
function pre_submission_handler_754( $form ) {
	GFCommon::log_debug( __METHOD__ . '(): Original POST => ' . print_r( $_POST, true ) );
	// change 3 here to the ID of your list field
	$list_field = rgpost( 'input_3' );
	// flip the array keys with the values so we can ...
	$list_field = array_flip( $list_field );
	// change the case of the array keys
	$list_field = array_change_key_case( $list_field, CASE_UPPER );
	// then we flip the keys with the values again, and assign back to the $_POST
	// change 3 here to the ID of your list field again
	$_POST['input_3'] = array_flip( $list_field );
	GFCommon::log_debug( __METHOD__ . '(): Modified POST => ' . print_r( $_POST, true ) );

I tried your code and change it with my form id and field id. Somehow it works however it did not save some of the fields. example

i have 3 cell in the list field. when i add values of each cell it only saves only one.
Cell1 = 23
Cell2 = 20
Cell 3 = 22

When i check in the backend, It only save the values of cell3 which is 22. I dont know if i miss something. Thoughts?

If I may ask, what is the purpose of the uppercasing of the data? Is it to be displayed as such somewhere? If that is the case, you could just use CSS to uppercase the displayed text, not so?

I already have text-transform: uppercase in css.

But the main use of uppercasing the values of my list field is to make more professional look when customer view in the email. Because my list field contains automotive part# and they must be in uppercase.

Any response would be appreciated!

© 2008 - 2021. Gravity Forms is a project by Rocketgenius Inc.