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.

Dynamically populating fields from another form

  1. SaraJ
    Member

    Hi,

    We've been using this great plugin, Participants Database to manage registration and enrolment at our preschool. The features it provides are wonderful in terms of functionality. It allows interested parents to fill out a preliminary form, which creates a record of their inquiry in the database. If they choose to register, we can email them a link to a longer registration form that has the fields they've already filled out populated and they can continue to edit their form. If at any time they wish to change the form or add information, we can resend the link.

    My problem is this, we'd like to add more information to the registration form and formatting the forms to be remotely attractive and useable is very challenging. I am so impressed with the Gravity Forms UI and the forms it produces. I'd also really like to be able to use some of the add-on features like paypal and mail chimp integration.

    My question is this - does the above scenario sound replicable in Gravity forms? I have been pouring over the documentation and I have read through the instructions for dynamically populating fields and using parameter_names. I'm a little lost on how to take information from one form to populate a second form that could be sent to the individual to complete (in the form of an emailed link). Is this even possible? It seems like it is...I just haven't found that scenario in the questions already asked.

    Secondly, if this is not possible, would it be possible to create a Gravity Form that would then feed the information into our "participants database" that we are already using? If so, could you point me in the direction of the right hook to use?

    Thanks so much for your time...and so sorry if these questions are answered somewhere!
    Sara

    Posted 11 years ago on Wednesday January 9, 2013 | Permalink
  2. You can certainly collect data with one form and send it to another form, pre-populating whatever fields you want in your second form. You could alternately send the data to another database with some PHP code and our gform_after_submission hook. http://www.gravityhelp.com/documentation/page/Gform_after_submission

    If you have a specific scenario of the information you want to collect with one form, and how it would be used to populate the second form, please share it here and I will try to find you a relevant example.

    Just as an example, you could use a link like this to send to a user, and it will populate the relevant fields in the form. http://gravity.chrishajer.com/pre-populate-everything/?fullname=sara&highschool=JFK&fruit=Melon&shoe=7.5

    Remove a few of those parameters and you will see that some fields are still pre-populated. That is pre-populating the values using the shortcode. There are several ways to pre-populate form fields. http://www.gravityhelp.com/documentation/page/Allow_field_to_be_populated_dynamically

    Posted 11 years ago on Thursday January 10, 2013 | Permalink
  3. SaraJ
    Member

    Thanks so much for your reply Chris.
    Here is a link to our current pre-registration form ( I know, the radio button are hideous!). When a user submits this form, their data is submitted to the database and their record is created. When they are ready to register, we send them a link like this so they can fill out the long registration form.

    We obviously don't want to have to create a link like the one in the example you gave me for each family manually. Is there a way for me to generate the long registration form with the pertinent fields from the pre-registration form populated and send it to the user to complete?

    I hope those examples make my question a bit more clear.

    As for feeding the data from a gravity form into our database, I tried it, using the code snippet from example two in the documentation for Gform_after_submission, but I couldn't get it to work. Here is my sample gravity form and the code I put in the functions.php file:

    [php]
    <?php
    add_action('gform_after_submission_5', 'post_to_third_party', 10, 2);
    
    function post_to_third_party($entry, $form) {
    
        $post_url = 'http://upperlonsdalepreschool.com/pre-registration/';
      	$body = array(
            'parent_1_first_name' => $entry['1.3'],
            'parent_1_last_name' => $entry['1.6'],
            'email' => $entry['3']
    
            );
        $request = new WP_Http();
        $response = $request->post($post_url, array('body' => $body));
    }
    
    ?>

    But this failed to create a new entry.

    Thanks so much for your speedy reply - I really appreciate the support.
    Sara

    Posted 11 years ago on Thursday January 10, 2013 | Permalink
  4. When you say "link like this" with the pid in it, is that pid the key to pull the information from your other database and fill in the form?

    Regarding debugging the external database, I would check to be sure the $body array contains all the values as you expect, before sending them to the $post_url. Check the value of $request before you send it, then check the $response. Also, with the URL and body created, try just accessing that from a command line or browser. Be sure you have the values you need, and be sure you're sending it to the correct place, then see what comes back.

    Posted 11 years ago on Thursday January 10, 2013 | Permalink
  5. SaraJ
    Member

    When the user fills in the pre-registration form, the database gets populated with their information and the pid is automatically created. Then if we send them the link: http://upperlonsdalepreschool.com/registration-form/?pid=_____ with their pid attached, they get the form, with their personal info filled in. There is a shortcode on the page http://upperlonsdalepreschool.com/registration-form/ that will only show the form if there is a pid in the url. As for the inner workings of what is exactly going on to populate the fields, I can't say for sure, but your assumption seems correct.

    I am leaning toward trying to create a gravity form that will populate our current database using gform_after_submission. If I can't figure it out in the next couple of days I'll just suffer with the ugly form :) Registration starts in a couple weeks!

    The solution I am going to go for is this...have a preregistration form that interested parents can fill out. We'll have a seperate long registration form for those who want to enrol, but I don't think I need to have the pre-reg form populate the other one, it's nice to have but not essential. Then when the user submits the form, I'll try to get it to populate our participants database, because it has other features such as lists and directories that are really handy. I only have a smattering of php knowledge so I'm going to try to sit down with my brother, who is a developer, to figure it out. I think if we try to solve it here it could be your full time job for the next week!

    For future reference, is there a hook or code snippet that pulls information from one form to populate another? For some reason this is still unclear to me. I'm thinking of not just populating the long form from the shorter one but other things like creating our emergency response forms that just contain the students medical information (right now those are created in a merge document in word from a csv file). I'll be leaving this in the hands of someone else in about 6 months(with even less knowledge than me!) and the less steps there are to registration, the better.

    Thanks so much again for your time.

    Posted 11 years ago on Thursday January 10, 2013 | Permalink
  6. How much progress did you make with this? Is there anything you need help with at this point?

    Posted 11 years ago on Thursday January 17, 2013 | Permalink
  7. SaraJ
    Member

    Thanks Chris,

    I decided not to persue trying to get the databases to share information. I'm going to create a portion of the registration form today using GF and will hopefully have some sucess with dynamically populating a few fields from one form to the next (like name, medical info etc). I think I can figure that much out from the documentation. If I need help, I'll check back in.

    thanks,
    Sara

    Posted 11 years ago on Friday January 18, 2013 | Permalink
  8. If you need help, go ahead and start a new topic and we'll help you resolve one issue at a time. Thanks.

    Posted 11 years ago on Friday January 25, 2013 | Permalink

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