gpnf-gravity-view-values.php

Output value instead of label for choice-based fields when using {all_fields} template or Nested Forms merge tag.

Code

Filename: gpnf-gravity-view-values.php

<?php
/**
 * Experimental Snippet 🧪
 * Output value instead of label for choice-based fields when using {all_fields} template or Nested Forms merge tag.
 */
add_filter( 'gform_merge_tag_filter', function ( $field_value, $merge_tag, $options, $field, $raw_field_value ) {
	$child_form_id        = 463;        // Change this to the child form's ID
	$fields_to_use_values = array( 1 ); // Change this to the radio field ID, multiple can be specified with commas, example: array( 1, 17, 8)
	$is_view              = ( class_exists( 'GV\Request' ) && GV\Request::is_frontend() );
	if ( ! $is_view || empty( $field->choices ) || ! in_array( $field->id, $fields_to_use_values ) || $field->formId !== $child_form_id ) {
		return $field_value;
	}

	return $raw_field_value;
}, 10, 6 );

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.