Using Gravity Forms ‘gform_submit_button’ PHP filter

The gform_submit_button Gravity Forms filter is used to modify the form’s submit button tag when the form is displayed.


To apply your function to all forms:

add_filter('gform_submit_button', 'your_function_name', 10, 2);

To target a specific form, append the form id to the hook name (format: gform_submit_button_FORMID):

add_filter('gform_submit_button_5', 'your_function_name', 10, 2);


  • $button_input (string): The string containing the <input> tag to be filtered.
  • $form (Form Object): The form currently being processed.

More information

See Gravity Forms Docs: gform_submit_button


Change input to button

Change the default input type to use the button element with an included span, which is popular for implementing the Sliding Door CSS technique.

add_filter('gform_submit_button', 'form_submit_button', 10, 2);
function form_submit_button($button, $form) {
    return "<button class='button gform_button' id='gform_submit_button_{$form['id']}'><span>Submit</span></button>";

Add text after the button

Add content after the submit button.

add_filter('gform_submit_button_36', 'add_paragraph_below_submit', 10, 2);
function add_paragraph_below_submit($button, $form) {
    return $button .= "<p>your <a href=''>text</a> goes here</p>";

Remove the button

Remove the submit button for a specific form.

add_filter('gform_submit_button_10', '__return_empty_string');

Append a JavaScript action to the button

Add an onclick action to the submit button.

add_filter('gform_submit_button', 'add_onclick', 10, 2);
function add_onclick($button, $form) {
    $dom = new DOMDocument();
    $dom->loadHTML('<?xml encoding="utf-8" ?>' . $button);
    $input = $dom->getElementsByTagName('input')->item(0);
    $onclick = $input->getAttribute('onclick');
    $onclick .= "addAdditionalAction('Additional Action');";
    $input->setAttribute('onclick', $onclick);
    return $dom->saveHtml($input);

Append custom CSS classes to the button

Add two custom CSS classes to the submit button.

add_filter('gform_submit_button', 'add_custom_css_classes', 10, 2);
function add_custom_css_classes($button, $form) {
    $dom = new DOMDocument();
    $dom->loadHTML('<?xml encoding="utf-8" ?>' . $button);
    $input = $dom->getElementsByTagName('input')->item(0);
    $classes = $input->getAttribute('class');
    $classes .= " my-custom-class another-one";
    $input->setAttribute('class', $classes);
    return $dom->saveHtml($input);