Force Rehydration When Editing Entry

Code

Filename: gppa-force-rehydration-on-edit.php

<?php
/**
 * Gravity Perks // Populate Anything // Force Rehydration When Editing Entry
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 */
add_filter( 'gform_get_field_value', function( $value, $entry, $field ) {
	static $_gppa_forcing_hydration;
	if ( GFForms::get_page() === 'entry_detail_edit' && ! $_gppa_forcing_hydration && gp_populate_anything()->is_field_dynamically_populated( $field ) ) {
		$_gppa_forcing_hydration = true;
		$hydrated_field          = gp_populate_anything()->hydrate_field( $field, GFAPI::get_form( $field->formId ), $entry, $entry );
		$value                   = $hydrated_field['field_value'];
		$_gppa_forcing_hydration = false;
	}
	return $value;
}, 10, 3 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.