I recently wanted to use Gravity Forms to load previously captured data and allow it to be edited and re-saved to the database. But after a lot of reading on the support forums I couldn't find any more than a few clues and vague pointers so after a fair bit of work I've got it working (mostly, this is still a work in progress, but more on that as we go). So in response to my conversation with Admin Chris in this thread:
Here is what I've done and how, step by step.
If you just want the code, please see here:
Firstly to set the scene I'm implementing this in quite a particular way but the basics should work with anything. I'm using the Types and Views plugins along with the Custom Post Fields plugin for Gravity Forms. I've used Types to create a custom post type (the one featured here is called Surgery) and it is displayed with a View, if you want to understand more about this please look them up but it is irrelevant to the rest of this post.
The first thing I did was dynamically populate the "editing" form with the data to edit. On my site the information is displayed and there is a button next to it which is clicked to load the edit form and this was done using a manually written shortcode: http://pastie.org/4495953. You should also note there is a part of this code that adds "bar=no" to the url, this is part of another function by Yoast that prevents the Wordpress admin bar from loading on this page. The main bits we're interested in are:
1. The Wordpress function "add_shortcode" which the first parameter names the shortcode and the second is the function name. So this code produces the shortcode [editphone].
2. Create the function corresponding to the add_shortcode
3. Set the page url of the editing form to the variable $edit_address
4. Pass the dynamically populating parameter the current post id to the $surgery_parent variable. If you are not using the "bar=no" bit you need to start this parameter with a ? not an &. This is because the ? denotes the end of the url and start of parameters and the & shows the break between parameters. So "original_post_id" is the parameter and "get_the_ID()" is a Wordpress function that returns the current item id, in this case the post we're viewing.
5. The next line just stitches together the first few variables to form the complete url.
6. Next I outline some classes that the link will have. "iframefancybox2" is not a CSS class a such but is seen by the Fancybox for Wordpress plugin and defines the correct Fancybox to load the form in. This is not important, I simply chose to use an iframe, you don't have to. "small-button" is simply styling for the link.
7. Finally put it all together into a complete link and return it and there we go, one working shortcode that passes the post id to a form.
Now I know I've prattled on for while and got no where near editing, however I have found these forums don't often go into enough detail as most of the users are very familiar with GForms, Wordpress and PHP so I want to break this down for those who, like me a few months ago, felt totally lost.