Hydrate form on Entry List page to include dynamic choices

Experimental Snippet 🧪

Installation: https://gravitywiz.com/documentation/how-do-i-install-a-snippet/

Limitations:

  • This snippet will not work with fields that have dynamically populated choices that are dependent on another value in the entry

Code

Filename: gppa-hydrate-choices-on-entry-list.php

<?php
/**
 * Gravity Perks // Populate Anything // Hydrate form on Entry List page to include dynamic choices
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 *
 * Experimental Snippet 🧪
 *
 * Installation: https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
 *
 * Limitations:
 *  - This snippet will not work with fields that have dynamically populated choices that are dependent on another
 *    value in the entry
 */
function gppa_hydrate_form_entry_details( $form ) {
	if ( ! class_exists( 'GP_Populate_Anything' ) ) {
		return $form;
	}

	if ( ! method_exists( 'GFForms', 'get_page' ) || GFForms::get_page() !== 'entry_list' ) {
		return $form;
	}

	remove_filter( 'gform_form_post_get_meta', 'gppa_hydrate_form_entry_details' );
	$form = gp_populate_anything()->hydrate_form( $form, array() );
	add_filter( 'gform_form_post_get_meta', 'gppa_hydrate_form_entry_details' );

	return $form;
}
add_filter( 'gform_form_post_get_meta', 'gppa_hydrate_form_entry_details' );

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.