gpadvs_js_init_args
Description
Allows you to filter the arguments passed to GP Advanced Select Field JS controller classes.
This is useful for things such as modifying the minimum search length, or enabling lazy loading for fields.
Usage
Apply to all GPADVS enabled fields on a specific form.
add_filter( 'gpadvs_js_init_args_FORMID', 'my_custom_function' );
Apply to a specific GPADVS enabled field on a specific form.
add_filter( 'gpadvs_js_init_args_FORMID_FIELDID', 'my_custom_function' );
Parameters
init_args array
Argument array that is used when initializing the field’s JS. The following properties are passed in the $init_args array:
formId string
The id of the current form.
fieldId string
The id of the current field.
lazyLoad boolean
Whether or not to lazy load GP Populate Anything search results.
usingSearchValue boolean
Whether or not the field should use a search value from GP Populate Anything.
hasImageChoices boolean
Whether or not the field currently has the Jet Sloth Image Choices plugin active.
fieldType string
The current field type.
minSearchLength int
The minimum character limit before a GP Populate Anything search query is made. (default is 3)
ignoreEmptySearchValue boolean
Whether or not all GP Populate Anything search results should be loaded upon initial field focus. (default is false)
form array
Current form.
field array
Current field.
Since
This filter is available since Gravity Forms Advanced Select 1.0.
Examples
Change the minimum GPPA search query length
add_filter( 'gpadvs_js_init_args', function ( $init_args, $form, $field ) {
$init_args['minSearchLength'] = 1;
return $init_args;
}, 10, 3 );
Immediately load all dynamic GPPA results
This is useful if you want all search results to show up right away when a Select Field gains focus.
add_filter( 'gpadvs_js_init_args', function ( $init_args, $form, $field ) {
$init_args['ignoreEmptySearchValue'] = true;
return $init_args;
}, 10, 3 );