Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to populate a form with an entry to a form with the exact same fields. Dynamic population is allowed. Currently I'm using PHP to just grab all the data like so:

   $lead = RGFormsModel::get_lead( $lead_id ); 
   $form = GFFormsModel::get_form_meta( $lead['form_id'] );  

Then iterating through to get the param names and variables. I'm finding I have to write a lot of 'case specific' code for some form sections (lists and checkboxes).

I'm guessing there is probably an easier way in existence.

share|improve this question
What does Gravity Forms support and documentation say about your request? –  kaiser Nov 3 '13 at 22:31
The documentation doesn't say anything about this in particular. The Support board is not available to me. –  Jon Lachonis Nov 4 '13 at 4:11
add comment

1 Answer 1

I figured it out. This function will work for all of the input types and assumes that you've passed a form id and entry id.

$form_id = $_GET['form'];
$lead_id = $_GET['entry'];
$lead = RGFormsModel::get_lead( $lead_id ); 
$form = GFFormsModel::get_form_meta( $lead['form_id'] ); 
$keys = array_keys($lead);
$params = array();
for ($i=0; $i<sizeof($keys); ++$i) {

$keysearch = $keys[$i];
$subarray = ff_keysearch($form,'id',$keysearch);
$test =  ff_keysearch($form,'id', intval($keysearch));
$field = FALSE;

if ($test[0]['type'] == "checkbox") { $field = $test[0]['inputName'];  }
    if(!$field) $field = ($subarray[0]['inputName'] ? $subarray[0]['inputName'] : $subarray[0]['name']);
if (($test[0]['type'] == "list")&&($lead[$keys[$i]])) {
    $paramstring = "";
    $decon = unserialize($lead[$keys[$i]]);
    $listkeys = array_keys($decon[0]);
        for ($ctr=0; $ctr<sizeof($listkeys)-1; ++$ctr) {
            foreach ($listkeys as $lkey) {
              $paramstring .=  $decon[$ctr][$lkey];
              if ($lkey != $listkeys[sizeof($listkeys)-1]) {  $paramstring .= "|"; } elseif ($ctr < sizeof($listkeys)-2) {$paramstring .= ",";}

        $params[$field]  = $paramstring;
        if ($lead[$keys[$i]] ) {
    $params[$field] =  $lead[$keys[$i]]; 

gravity_form($form_id, true, true, true,$params, false); 

function ff_keysearch($array, $key, $value)
    $results = array();
    if (is_array($array))
        if (isset($array[$key]) && $array[$key] == $value)
            $results[] = $array;
        foreach ($array as $subarray)
            $results = array_merge($results, ff_keysearch($subarray, $key, $value));
    return $results;
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.