Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Dynamically populate Gravity Form fields across pages WordPress

  • SOLVED

We have a problem in Gravity Forms -

We need to be able to populate fields on the last page of a Gravity from from a custom post type based on a user's answers to questions on page 1 of the form. We can get it to work for questions/fields on the same page, but not for fields on different pages.

We're using the latest version of WP and Gravity Forms.

Answers (6)

2014-02-21

Arnav Joy answers:

can you show the form please.

2014-02-21

Hariprasad Vijayan answers:

Hi,

Check this threads
http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population
http://www.gravityhelp.com/documentation/page/Allow_field_to_be_populated_dynamically

2014-02-21

Ryan S answers:

Hi have you tried using Dynamic Population? you can found more here http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population


Hope that help

2014-02-21

Sébastien | French WordpressDesigner answers:

if you want I can do that.
send me your bakoffice access
[email protected]

2014-02-21

Dbranes answers:

The problem with the <strong>gform_field_value_{parameter}</strong> hook is that it's only activated on the first form page and will fill the $_POST array with those values.

So it will probably not help you if you need to adjust these values later (to prefill some answers), based on answers on other pages.

Here's an idea how to solve your problem:


<strong>Example:</strong>

If you have for example this setup:


Page 1:

Question 1 input text with a field id 11

----

Page 2:

Question 2 input text with a field id 14

----

Page 3:

Question 3 input text with a field id 15



then you could use (just a simple demo):

add_action( 'init', function(){

// get answers for q1 and q2
$q1_ans = filter_input( INPUT_POST, 'input_11' );
$q2_ans = filter_input( INPUT_POST, 'input_14' );

// pre fill answer for q3 based on q1 and q2
if( 'london' === $q1_ans && 'paris' === $q2_ans )
{
$_POST['input_15'] = 'dakhar';
}
});


to prefill the answer.

You can further add a check for the <em>form id</em> and the current <em>form page number</em>.

The $_POST array might look like this on page 3:

Array (
[input_11] => london
[input_14] => paris
[input_15] => dakhar
[is_submit_3] => 1
[gform_submit] => 3
[gform_unique_id] => 53071c13c022b
[state_3] => abc123
[gform_target_page_number_3] => 3
[gform_source_page_number_3] => 2
[gform_field_values] =>


Dbranes comments:

Just let me know if you need further assistance with the problem.

cheers

2014-02-21

Nile Flores answers:

No voting, but a suggestion- This is solved with the Gravity Forms Survey add-on that is available to those with a developer license.