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.

Redisplay last form populated from database

  1. Hi,

    Is there an easy function call in your library to redisplay an entire form with all fields populated with the database contents just submitted?

    My scenario is I'm using a form to capture payment info to be sent to I'm sending code to them using the post submission hook, so I'm still on the original form page after submit, but of course when you submit then Gravity Forms pops up the confirmation message so the form is now gone. However, can reply there's an error with a field, in which case the form needs to be redisplayed filled in so the user can correct that error.

    If there's no quick call to retrieve the form data, do you have a handy code snippet that reads the database to populate a form with data for a particular lead ID?

    I supose I could write javascript to trap all the errors before form submission but since traps errors for me with no codiing on my part it's much easier to just display their response and give the user the form again to correct.

    Of course, hopefully someday Gravity Forms will allow us to create richer custom error trapping from the GF UI when creating forms.

    Posted 11 years ago on Wednesday February 3, 2010 | Permalink
  2. Hello,

    Yes, there is a function call you can use to get the entry by id.
    You will need to do the following in order to accomplish what you need:

    1- Use the pre_render hook to populate a global $entry variable

    //Replace 22 with the actual form id
    add_filter("gform_pre_render_22", populate_entry);
    function populate_entry($form){
        global $entry;
        //assuming entry id will be sent via Query String
        $entry_id = $_GET["entry_id"];
            $entry = RGFormsModel::get_lead($entry_id);
        return $form;

    2- For each field that needs to be populated,
    a- Check the "Allow field to be populated dynamically" on the advanced tab of the editor
    b- Give it a parameter name (of your choice)

    c- Add a hook to populate the field's value

    add_filter("gform_field_value_PARAMETERNAME", "populate_field1");
    function populate_field1($value){
        global $entry;
        return $entry[1]; //replace 1 with your field id
    Posted 11 years ago on Wednesday February 3, 2010 | Permalink