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.

Update another forms entry with second form

  1. johncobbs
    Member

    I have two forms. The second would allow a reviewer to update some values from the first submission. I was planning to invoke the gform_after_submission hook on the second form but got stuck trying to find a hook that would allow me to update the first form's entry if I feed it the form obj, entry ID and field ID plus the new value. Have considered using the save_field_value hook and passing the form obj, etc from form #1 but wondering if there is a better way?

    This topic sounded like it was asking the same question but was maybe more about the Admin update than a code level update: http://www.gravityhelp.com/forums/topic/gform_after_submission-in-backend-and-entry-modification

    Thanks in advance for any help,
    John

    Posted 12 years ago on Monday November 5, 2012 | Permalink
  2. Sounds like you should use gform_after_submission after the second form is submitted. At least you know that code will run after your second form is submitted, and you have all the data you need from that submission. It sounds like you also have the form ID from the first form. How will you know the field IDs and entry IDs to be updated in form 1?

    Your function will be hooked to gform_after_submission, which is where you will get the values you need to update the entry made by form 1. Looking through forms_model.php around line 2071, I see this function:

    [php]
    public static function save_input($form, $field, &$lead, $current_fields, $input_id) {

    I think you could use it like this:

    [php]
    RGFormsModel::save_input($form, $field, &$lead, $current_fields, $input_id)

    and use the form ID for form 1 and the lead ID you want to update as well.

    Posted 12 years ago on Wednesday November 7, 2012 | Permalink