State Abbreviations don't show [RESOLVED]

Hi Experts,
I researched and found the add filter code in gravity form docs to make the address field show the state abbreviations. Added this code to my child themes function file, but it doesn’t work. Here is the sample page I added the sample form to:

Can you help me get this code right?

Most Appreciated,

   add_filter( 'gform_us_states', 'us_states' );
function us_states( $states ) {
    $new_states = array();
    foreach ( $states as $state ) {
        $new_states[ GF_Fields::get( 'address' )->get_us_state_code( $state ) ] = $state;
    return $new_states;

Hi Diana. The code is working on your site. It does not change the display value, just the stored value. This will store the 2 letter state code in the entry, and is required for some add-ons. Looking at the source of your page, I can see it is working as expected:

<option value='IL' >Illinois</option>

Are you trying to accomplish something else?

1 Like

Hi Chris,
Once again you are there for me! Thank you!
All is good with your explanation. I just wanted the abbreviation to be passed to the entries. I guess I should of tested the form but though visually the list would show the abbreviations.

Merry Christmas to you,

Thanks Diana. Merry Christmas.