Correct data field after submission [RESOLVED]

Hi Gravity Community,

I was wondering if there was a way to correct the data after form submission ?
For example : One of my client wants to receive city name without hyphen, We use a google maps autocompletion plugin on this field and city names can have hyphens.

maybe using a function with “gform_save_field_value” ?

i tried that :

add_filter( ‘gform_save_field_value_1_24’, ‘remove_hyphen’, 10, 3 );
function remove_hyphen($value, $entry, $field, $form) {
$new_value = str_replace(’-’, ’ ', $value);
return $new_value;
}

but it crashes my form…

Thx a lot

This code should work. There were some fancy quotes in there, but I am not sure if that is the forum software correcting that, or if that was in your code. Please try this:

// applies to form 1, field 24
add_filter( 'gform_save_field_value_1_24', 'remove_hyphen', 10, 5 );
function remove_hyphen( $value, $lead, $field, $form, $input_id ) {
	// replace hyphens with spaces
	$new_value = str_replace( '-', ' ', $value );
	return $new_value;
}

Hi Chris,

Thank you, that was exactly the problem.
Now it works like a charm.

Thx a lot !

1 Like