Here’s the sitch: I’m using a multi-page Gravity Form in conjunction with an external API.
On the first page of the form, the user supplies a phone number. On a subsequent page, I need to send the external API the phone number in order to retrieve the user’s current settings, which then must be prepopulated in other fields.
I know how to use gform_post_paging, but since $entry
hasn’t been created yet I can’t use it to pull fields from previous pages.
gform_pre_submission/gform_after_submission
don’t help me because I need to make the API call prior to users reaching the end of the form.
I’ve also tried handling this via jQuery, by pulling and storing the value of the phone field on page advancement (e.g. var phoneNum = jQuery('#input_2_25').attr('value');)
, but I get “undefined” no matter what when using field ids. (It works fine, in the same location, looking for other ids on the site, so the issue isn’t with jQuery.) I’m guessing this means that between pages, the form elements don’t exist in the view?
How can I accomplish this goal (i.e., retrieving a value from a previous page in a multi-page Gravity Form prior to the user reaching the end of the form)?
All of the data is stored in the $_POST variable on each page submission. Gravity Forms has a helper function for accessing $POST data. The format for the variable name will be
'input
{fieldId}’.