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.
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
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
Sébastien | French WordpressDesigner answers:
if you want I can do that.
send me your bakoffice access
[email protected]
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
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.