Skip to content

Instantly share code, notes, and snippets.

@curtismchale
Last active February 25, 2026 23:53
Show Gist options
  • Select an option

  • Save curtismchale/d90d5117f8c53e607bdc67a8e11635ad to your computer and use it in GitHub Desktop.

Select an option

Save curtismchale/d90d5117f8c53e607bdc67a8e11635ad to your computer and use it in GitHub Desktop.
We're trying to add an option to the gravity forms submit button on each form. The checkbox shows up but doesn't stay checked through a save of the form. I’m using the appearance settings filter because that seems to be the right one, though I grabbed the code from the advanced settings example because there were no examples provided in the appe…
<?php
/**
* Adds an "Apply Action Button Color" checkbox to Form Settings → Form Button.
* GF's Settings API natively handles saving and restoring the value on the form object.
*/
function proud_action_button_form_setting($placement, $form_id)
{
if ($placement == 50) { ?>
<li class="action_setting field_setting">
<input type="checkbox" id="proudActionButton" onclick="SetFieldProperty('proudActionButton', this.checked);" />
<label for="proudActionButton" style="display:inline;">
<?php _e("Action Button", "your_text_domain"); ?>
<?php gform_tooltip("form_field_action_color") ?>
</label>
</li>
<?php
}
}
add_filter('gform_field_appearance_settings', 'proud_action_button_form_setting', 10, 2);
function proud_editor_script()
{
?>
<script type='text/javascript'>
//adding setting to fields of type "text"
fieldSettings.submit += ", .action_setting";
//binding to the load field settings event to initialize the checkbox
jQuery(document).on("gform_load_field_settings", function(event, field, form) {
jQuery('#proudActionButton').prop('checked', Boolean(rgar(field, 'proudActionButton')));
});
</script>
<?php
}
add_action('gform_editor_js', 'proud_editor_script');
function proud_add_action_button_tooltips($tooltips)
{
$tooltips['form_field_action_color'] = "Checking this will apply the action button color from the Customizer to the form submit button.";
return $tooltips;
}
add_filter('gform_tooltips', 'proud_add_action_button_tooltips');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment