Description
This filter is executed during the process of enqueing scripts for each form in the current page. When developing custom field types that require extra scripts, this hook should be used to enqueue the custom scripts when appropriate.
Usage
<?php
add_action("gform_enqueue_scripts", "enqueue_custom_script", 10, 2);
?>
You can also specify this per form by adding the form id after the hook name.
<?php
add_action("gform_enqueue_scripts_6", "enqueue_custom_script", 10, 2);
?>
Parameters
$form
- (Form Object) The current Form Object.
$is_ajax
- (bool) Specify if the form is configured to be submitted via AJAX.
Examples
This example enqueues a custom script for all AJAX forms.
<?php
add_action("gform_enqueue_scripts", "enqueue_custom_script", 10, 2);
function enqueue_custom_script($form, $is_ajax){
if($is_ajax){
wp_enqueue_script("custom_script", "path/file.js");
}
}
?>
Placement
This code should be placed in the header.php file of your active theme just before the wp_head() function call.
Source Code
This filter is located in form_display.php