Need Help Passing File to My Nested Child Form

Hi there,

I have a parent form with a nested child form in it, to submit projects.

The parent form has a rubric upload field, that should go into all of the child forms. But, I am having trouble passing this document field to the nested child form.

How can I achieve this? I have some ideas of how this may be able to be done, but am unsure what would be best:

My ideas:

  1. Upload a file to the parent, that will go into the child. - If a file will not work. Pass the URL of the file from the parent to the child? (Unsure, if this is possible, or how?)

  2. Have a separate gravity form for users to upload rubrics, which can then be dynamically selected in the parent form to go into the child form. I am able to use dynamic selection from a dropdown in the parent, but am not sure how to get the file into the child form?

  3. My third idea is to have a separate gravity form that converts the document to text with the Open AI Gravity Wiz add on, then populate the text some how in my child form. Is that even possible?

Really appreciate everyones help here! This has been a pain point of mine finding the best solution.

Hi Melissa,

You can use the code snippet below to pass the uploaded file on the parent form to the child form file upload field or even a text field, after the parent form has been submitted.

// Update "123" to your form ID.
add_filter('gform_entry_post_save_123', function ($entry, $form) {

    $parent_file_upload_id = 4;  // Update '4' to the id of the file upload field on the parent form.
    $child_field_id = 5;         // Update '5' to the id of the file upload field on the child form.
    $nested_form_field_id = 6;   // Update '6' to the id of the nested form field on the parent form.

    $image_url = rgar( $entry,$parent_file_upload_id );
    $parent_entry = new GPNF_Entry( $entry );
    $child_entries = $parent_entry->get_child_entries( $nested_form_field_id );

    foreach( $child_entries as $child_entry ){
        GFAPI::update_entry_field( $child_entry['id'], $child_field_id, $image_url );
        $child_entry[ $child_field_id ] = $image_url;
    }
    return $entry;
}, 5, 2);

Please update the IDs as commented.

I hope this helps.

Best,