gform_load_field_choices

Description

This JavaScript hook allows help text to be displayed below the choices in the Form Editor.

Note: This hook in used in the Gravity Forms Quiz and Survey add-ons.

Usage

gform.addAction('gform_load_field_choices', function (field) 
  {
      //do something
  }
);

Parameters

Examples

This example uses the gform_admin_pre_render action to load the hook.

add_action( 'gform_admin_pre_render', 'pre_render_function' );
function pre_render_function( $form ) {
	?>
	<script type="text/javascript">
		jQuery(document).on("gform_load_field_choices", function(event, field){
			//write text to the field's description
			formId = field.formId;
			fieldId = field.id;
			jQuery('#gfield_description_' + formId + '_' + fieldId).html('This is a test');
		});
	</script>
	<?php
	return $form;
}

This example uses the gform_editor_js action to load the hook.

add_action( 'gform_editor_js', 'add_script_to_editor' );
function add_script_to_editor() {
	?>
	<script type='text/javascript'>
		gform.addAction('gform_load_field_choices', function( ){
			field = GetSelectedField();
			//write text to the field's description
			formId = field.formId;
			fieldId = field.id;
			jQuery('#gfield_description_' + formId + '_' + fieldId).html('This is a test');
		});

	</script>
	<?php
}

Placement

Your code snippet can be placed in an HTML field on your form, in a theme custom JavaScript file, in the gform_admin_pre_render hook or the gform_editor_js hook in the functions.php file of your active theme.

Since

This filter was added in Gravity Forms version 1.7.

Source Code

This filter is located in LoadFieldChoices() in js/form_editor.js.