Add class to GF submit button

<?php
function form_submit_button($button,$form){
return '<input type="submit" class="btn" id="gform_submit_button_' . $form['id'] . '" value="' . $form['button']['text'] . '">';
}
add_filter('gform_submit_button','form_submit_button',10,2);
?>

4 Comments

You must be logged in to post a comment.


  1. Thanks


  2. Probably not a great idea to just completely overwrite the button HTML. Gravity Forms does alot of processing to add things for JS hooks, Events, Ajax etc.

    There is a plugin https://github.com/pbc-web/gravityforms-add-button-class that adds classes to the submit button via a form on the backend. It parses the HTML in a filter to add new classes.


  3. Thanks for the code.


  4. Thanks for this!

    I think though that it's missing some security precautions, so I've adapted the same code here: https://gist.github.com/fjarrett/8259070