Update existing entry with second submission

Scenario: Form is submitted creating entry #1. A special link brings user to the same form pre-filled with entry #1 values. Form is submitted, updates entry #1 with changed values, confirmations and notifications are processed again.

I only need help with the second submission, how to overwrite the original entry, without creating a second entry. I tried doing this multiple ways, the biggest hiccup involved file upload fields.

Any suggestions? Thanks!

How about using this filter to change the entry ID before save?

Thanks for the reply Chris! Yes, that filter works and it was part of my initial attempts. What can I do about a file upload field? If entry #1 has file uploads, how can I output them pre-filled in a way that won’t erase/overwrite the uploads from entry #1?

When presenting entry #1 for review, I’m using the gform_field_content filter to output a hidden field (and iframes displaying the actual files, but that’s besides the point). The hidden field is not working, as the second submission results in the file upload field being cleared. Here’s the code:

//... code during gform_pre_render hook, entry #1 is located
$files = rgar($entry, $field->id) ) ) { // File Upload field

add_filter( "gform_field_content_{$form['id']}_" . $field->id, function ( $content, $field, $value, $entry_id, $form_id ) use ($files) {
	$content = '<input type="hidden" value="'.urlencode($files).'" name="input_'.$field->id.'" id="field_'.$form_id.'_'.$field->id.'">';

	//...additional $content...

	return $content;
}, 10, 5);

I’ve successfully used the gform_save_field_value filter to short-circuit overwriting the entry values (by returning an empty array), and this works! However, the result is an incomplete entry object that interferes with confirmations and notifications.

I think you are going to run into issues with browser security when attempting to pre-fill a file upload field. I’ll leave this open in case anyone can add any information.

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.