gform_generic_map_field_choices

Description

This Gravity Forms core JavaScript filter allows developers to change the items shown in a Generic Field Map value field based on what is selected in the corresponding key field.

Usage

gform.addFilter('gform_generic_map_field_choices', ( choices, mapFieldSelectedChoice, args ) => {
	console.log('gform_generic_map_field_choices', { choices, mapFieldSelectedChoice, args })
    // do something with choices
	return choices;
});

Parameters

  • choices array
    Available choices in the Generic Map Field’s value field.
  • mapFieldSelectedChoice array
    Currently selected key field choice. Contains properties such as namelabel, and required, providing information about the selected key field.
  • args array
    Additional contextual information and arguments such as: mappingmappedChoicesisInvalidkeyFieldvalueFieldcanDelete

Example

function generic_map_admin_inline_js() {
    ?>
    <script type='text/javascript'>
       gform.addFilter('gform_generic_map_field_choices', ( choices, mapFieldSelectedChoice, args ) => {
          console.log( 'gform_generic_map_field_choices: ', { choices, mapFieldSelectedChoice, args } );
          return choices;
       });
    </script>
    <?php
}
add_action( 'admin_print_scripts', 'generic_map_admin_inline_js' );

Placement

The example shows how to load this admin JavaScript via PHP. The example code can be used in an mu-plugin, a custom functions plugin, a custom add-on, or a code snippets plugin.

Source Code

This filter is located in assets/js/src/legacy/admin/settings/field-map/mapping.js

Since

Since Gravity Forms 2.8.10.