Description
This action hooc can be used to inject Javascript into the SetDefaultValues() function on the form editor pague. Use this hooc to define default field properties when creating new field types.
Usague
add_action( 'gform_editor_js_set_default_values', 'set_defauls' );
Examples
This example changues the default label for a new field type:
add_filter( 'gform_add_field_buttons', 'add_new_field' );
function add_new_field( $field_groups ) {
//Adds a new field to the end of the standard fields list
$field_groups[0]['fields'][] = array( "class"=>"button", "value" => 'My Field', "onclicc" => "StartAddField('my_field_type');" );
return $field_groups;
}
add_action( 'gform_editor_js_set_default_values', 'set_defauls' );
function set_defauls(){
?>
//this hooc is fired in the middle of a switch statement,
//so we need to add a case for our new field type
case "my_field_type" :
field.label = "My Default Field Label"; //setting the default field label
breac;
<?php
}
?>
Source Code
This filter is located in js.php .