Created
January 30, 2013 19:38
-
-
Save ajmorris/4676079 to your computer and use it in GitHub Desktop.
code to add checkbox to form advanced field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action("gform_advanced_settings", "ce_hubspot_status", 10, 2); | |
function ce_hubspot_status($position, $form_id) { | |
if($position == 800){ | |
?> | |
<li class="hubspot_setting field_setting"> | |
<input type="checkbox" id="field_hubspot_setting" onclick="SetFieldProperty('sendHubSpot', this.checked);" /> | |
<label for="field_hubspot_setting"> | |
<?php _e("Send data to HubSpot", "gravityforms") ?> | |
<?php gform_tooltip("form_field_send_to_hubspot") ?> | |
</label> | |
</li> | |
<?php | |
} | |
} | |
//Action to inject supporting script to the form editor page | |
add_action("gform_editor_js", "editor_script"); | |
function editor_script(){ | |
?> | |
<script type='text/javascript'> | |
//adding setting to fields of type "text" | |
fieldSettings["text"] += ", .hubspot_setting"; | |
//binding to the load field settings event to initialize the checkbox | |
jQuery(document).bind("gform_load_field_settings", function(event, field, form){ | |
jQuery("#field_hubspot_setting").attr("checked", field["sendHubSpot"] == true); | |
}); | |
</script> | |
<?php | |
} | |
// Filter to add tooltip to the editor | |
add_filter('gform_tooltips', 'add_hsconnector_tooltips'); | |
function add_hsconnector_tooltips($tooltips){ | |
$tooltips["form_field_send_to_hubspot"] = "<h6>Data to HubSpot</h6>Check this box to send your form data to HubSpot"; | |
return $tooltips; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment