Change the Value in Field to CAPITAL Letters [RESOLVED]

Hi,
i need an Function to CAPITALIZE or UPPERCASE the Value in Fields.

Why?:

  1. My client enters the details from an Car license plate into an Form.
  2. I need to create an Google Drive Folder with the Name
  3. The Structure of the Cr License Plate is for example. HH-IM-444
    So you see, that the Letters has to be in Capital Letters
  4. I want to make 3 Fields. 1 for ( HH ) then “-” Field 2 for (IM) then “-” and then the Numbers
  5. The Problem is, that if the Field 1 is filled with Hh, it is not in the same structure. So i want to convert “Hh” or “hh” to “HH” and so on.

I found the way to my solution, but as far as I understand, it is only for capitalizing the the First Letter.

Looking forward for your Feedback
Regards
Gerrit

You can do this by hooking into the filter gform_save_field_value. Specifically, see example 4. Uppercase Value for a basic example of setting all text inputs to uppercase. In your case, you’ll probably want to look at usage for targeting specific fields and then calling upon a function for uppercasing those values. Something like this would target Field ID 4 and Field ID 7 on Form ID 18:

add_filter( 'gform_save_field_value_18_4', 'uppercase_field_value', 10, 6 );
add_filter( 'gform_save_field_value_18_7', 'uppercase_field_value', 10, 6 );

function uppercase_field_value( $value, $entry, $field, $form, $input_id ) {

    GFCommon::log_debug( __METHOD__ . ': running.' );
    return strtoupper( $value );

}
1 Like