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.

Need help creating an edit form

  1. I'm starting using the code located in a post from 4 days ago (http://www.gravityhelp.com/forums/topic/displaying-entry-data-in-form#post-22281).

    I have a form that I want to use as an edit form so that if the Lead ID already exists, the form will pre-populate with the data that is already in the database.

    I have taken David Smith's code from http://pastie.org/1744975, added it to my functions.php file, set up a hidden field to capture the original Lead ID dynamically from the URL string, however it still isn't loading anything. I've tried a couple of different URL string syntax including http://www.mysite.com/edit-directory/?lid=12 and http://www.mysite.com/edit-directory/?/lid/12, however neither preloads the data in my form.

    Any idea what I'm doing incorrectly?

    thanks
    brian

    Posted 13 years ago on Wednesday April 6, 2011 | Permalink
  2. A few things to check:

    1. make sure the lid you are using "12" is a valid lid
    2. make sure the lid you are using was created by the form you are attempting to populate
    3. in the code snippet you are using, echo out the $lead_id after you attempt to retrieve it from the query to make sure it is being fetched correctly:
      [php]
      $lead_id = rgget('lid') ? rgget('lid') : 0;
      echo $lead_id;
    Posted 13 years ago on Wednesday April 6, 2011 | Permalink
  3. Thanks David,

    It looks like it's not being fetched correctly. If I echo out the $lead_id it doesn't display anything.

    so, maybe my next question, :) is how do I fetch it correctly?

    thanks
    brian

    Posted 13 years ago on Wednesday April 6, 2011 | Permalink
  4. Ok, I had the gform_pre_render_3 set up incorrectly. So now it is definitely fetching the function however it doesn't recognize rgget() so I get this error:

    Fatal error: Call to undefined function rgget() in /home/ventura1/public_html/wp-content/themes/672_wp/functions.php on line 1062

    Is rgget() from a newer version of GF? I'm using 1.4.5.

    thanks,
    brian

    Posted 13 years ago on Wednesday April 6, 2011 | Permalink
  5. Yep, rgget is available in 1.5. Is upgrading not an option for you? If not, just add this below the other snippet:

    http://pastie.org/1764594

    Posted 13 years ago on Wednesday April 6, 2011 | Permalink
  6. I can upgrade. Thanks for the snippet as well.

    Otherwise it works great, I explicitly declared the value of $lead_id and the form self-populated perfectly so I'll drop this snippet in and then upgrade which should do the trick.

    thanks
    brian

    Posted 13 years ago on Wednesday April 6, 2011 | Permalink
  7. radioswan
    Member

    Has anyone been able to get this to pre-render the 'advanced' address fields?

    I tried the following from another post but it's not working.

    case 'address':
                 $i = 1;
                foreach($field['inputs'] as $addr){
    				if(!isset($entry[$addr['id']])) {
                        $i++;
                        continue;
                    }
    				$x = (string) $addr['id'];
    				$val = $entry[$x];
                    $addr['defaultValue'] = $val;
                }
                break;
    Posted 12 years ago on Monday May 16, 2011 | Permalink
  8. Hi Radioswan,

    This turned out to be a bit more involved than I thought... but here is the code posted above updated to support the address field:

    http://pastie.org/1917904

    Posted 12 years ago on Tuesday May 17, 2011 | Permalink