Gravity forms $field_values not working

I am running the most curent version of WP and Gravity forms. I’m trying to call the form through a template file and pass through a few things like so:

gravity_form(2, $display_title=false, $display_description=true,
 $field_values, $ajax=true);

I’m calling the $field_values like so:

Read More
$field_values = array("my" => "FOO", "your" => "BAR",);

They are simple not populating into gravity forms. Any ideas?

Related posts

Leave a Reply

3 comments

  1. Make sure to click on the field and then click on the advanced tab and check mark the prepopulate field checkbox. This will drop down a text box in which you can specify a parameter name.

  2. Ok, lets say that your form ID is 7, let me give you a step-by-step answer:

    1. Create your form
    2. Go to advanced
    3. Check “Allow field to be populated dynamically”
    4. Give it a name, eg.: my_name
    5. gravity_form(7, false, false, false, array('my_name'=>'whatever you want to autofill'), false);

    Now if you go to that form you will see that the field which had the name my_name has the value whatever you want to autofill.

    Hope this helped, bye bye.

  3. This documentation gives some helpful advice on populating fields:

    gravityhelp.com/documentation/page/Allow_field_to_be_populated_dynamically

    and here is an example of how I populate fields using a hook:

    add_filter("gform_field_value_yourparametername", "populate_yourparametername");
    
    function populate_yourparametername($value){
        global $post; 
        $value = get_post_meta( $post->ID,'metakeyname',true);
       return $value;
    
    }
    

    In order for this to work, you must check the box in the advanced tab of the form item in your Gravity Form that allows the field to be populated dynamically. Then you need to fill in the input below with ‘youparametername’.