Get Value Selected in Source Field When Populating Choices in Target Field

Code

Filename: gppa-get-selected-source-field-value-when-populating-choices.php

<?php
/**
 * Gravity Perks // Populate Anything // Get Value Selected in Source Field When Populating Choices in Target Field
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 */
// Update "123" to your form ID and "4" to the ID of field for which you would like to customize the populated choices.
add_filter( 'gppa_input_choices_123_4', function( $choices, $field, $objects ) {
	// Update "5" to the ID of the field for which you would like to check the selected value.
	$selected_value = $GLOBALS['gppa-field-values'][ $field->formId ][5];
	return $choices;
}, 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.