When working on a project, using Gravity Forms and Bootstrap, I wanted to style the buttons with Bootstrap.
This code applies the Bootstrap Classes to the Gravity Forms submit button.
add_filter( 'gform_submit_button', 'fe_gravity_forms_btn_classes', 10, 2 );
/**
* Replace Gravity Forms button classes with Bootstrap button classes.
*/
function fe_gravity_forms_btn_classes( $button, $form ) {
return str_replace( 'gform_button button', 'btn btn-primary', $button );
}
For a different approach, see Jay Hoffman’s post on Using Gravity Forms with Bootstrap Styles. Instead of adding the Bootstrap classes he uses CSS (or Sass) to target the Gravity Forms class and apply the styles. Jay’s work has the advantage of applying the Bootstrap styles for the entire form, not just the submit button.
Leave a Reply