PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Dynamic population from variable fields

  1. stevorevo

    Hello -

    I'm developing a very large form and need to provide users the ability to come back at a later date, login, and continue where they left off. Dynamically populating form fields is pretty straightforward with the Wordpress add_filter method call. But you have to know the field name, and I would like to iterate through the form fields by querying the database, and populating the fields without having to know the field names. I've tried create_function but that does not work. Do you have any ideas on how I can do this?

    Thank you for any suggestions you can offer.


    Posted 9 years ago on Friday June 8, 2012 | Permalink
  2. stevorevo

    I should probably clarify a bit more. I'm using create_function, because the function name must contain the field name. So I was using create_function to dynamically create functions based on the field name(s). Is there any way I can use just one generic function, and pass in the field name as a parameter?

    Posted 9 years ago on Friday June 8, 2012 | Permalink
  3. David Peralty

    Check out our Developer Docs, you'll specifically want to look at Form Loading

    I would think our hook Gform_pre_render might help you:

    Posted 9 years ago on Monday June 11, 2012 | Permalink
  4. stevorevo

    Hi David - thank you for your reply. I'll take a look at that hook.

    Posted 9 years ago on Monday June 11, 2012 | Permalink
  5. stevorevo

    Hello David -

    That works perfectly. RGFormsModel::get_lead() really makes it easy, too.

    I have something else I need to do but haven't quite been able to find the hook that will help, and I'm hoping you can point me in the right direction. The client has decided they want to have the user complete one pre-application form. If they are approved, they can return to the site, and complete the application process on a multi-page form. Here's how I'm thinking I can accomplish this:

    1) user completes first form
    2) I save the lead_id to a cookie (if they have cookies disabled, I'll have them login with email/password)
    3) use RGFormsModel::get_lead() to get the data and populate the form, stashing the lead_id into a hidden field

    That's all straightforward. Where I'm having difficulty coming up with a solid solution is how to make sure the lead_id from the first form is the same as the lead_id from the rest of the application which is a different form.

    My initial thought was to use the gform_entry_created hook, grab the lead_id from the hidden field, and after the entry has been saved, update the newest entry, changing the lead_id to what's in my hidden field. Do you think that makes sense, or would you suggest a better way of doing it? Also, when going from one page to the next on a multi-page form, how is the lead_id tracked?

    Thanks so much for any help you can provide.


    Posted 9 years ago on Thursday June 14, 2012 | Permalink
  6. stevorevo

    When I say "changing the lead_id to what's in my hidden field" I mean changing it in the rg_lead_detail table.

    Posted 9 years ago on Friday June 15, 2012 | Permalink
  7. stevorevo

    In looking at this further, I'm not sure how it's going to work when it comes to the admin page for viewing entries. There are going to be field_number conflicts between one form and another if I just start changing the lead_id value in the lead_detail table when the forms are different.

    So what I'm thinking I'll do is have two forms. After users get approval one that first form, I am going to transfer that information over to the second form via hidden fields. Does this sounds like a viable solution?

    Thanks again,

    Posted 9 years ago on Saturday June 16, 2012 | Permalink
  8. David Peralty

    That sounds like a much better idea. I spent a while today trying to figure out how this would work. The developers are also working on a solution for the core of Gravity Forms, but it might not be ready for a while because of the huge list of priorities we have in the development stream right now.

    Try out your new solution and let me (and everyone) know if it works. All my best,

    Posted 9 years ago on Sunday June 17, 2012 | Permalink
  9. stevorevo

    The hidden fields work great. The only issue is that my client does not want the user to be able to edit these hidden fields. Is there a way I can create a separate form on my template page, then access the fields in that form when a gravity form is submitted? I would like to be able to programmatically add these fields in the pre-render hook but I don't think that is possible.

    Posted 9 years ago on Wednesday June 20, 2012 | Permalink
  10. Have you seen this one?

    Posted 9 years ago on Wednesday November 14, 2012 | Permalink
  11. Closing this topic as it is very old.

    Posted 9 years ago on Saturday November 17, 2012 | Permalink

This topic has been resolved and has been closed to new replies.