The gform_editor_js_set_default_values action hook is used to inject JavaScript into the SetDefaultValues()
function on the form editor page, allowing you to define default field properties when creating new field types.
Usage
add_action('gform_editor_js_set_default_values', 'set_defaults');
Parameters
None
More information
See Gravity Forms Docs: gform_editor_js_set_default_values
Examples
Change default label for a new field type
This example adds a new field type with a custom default label.
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', "onclick" => "StartAddField('my_field_type');"); return $field_groups; }
add_action('gform_editor_js_set_default_values', 'set_defaults');
function set_defaults() { ?> // This hook 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 break; <?php }