Gravity Forms: Customize the Submit Button HTML
Replaces the default Gravity Forms submit input with a styled button element including custom text, using the gform_submit_button filter.
PHPby SnipCraft
php
<?php
if ( class_exists( 'GFForms' ) && ! function_exists( 'scseed_gf_custom_submit_button' ) ) {
/**
* Replaces the default <input type="submit"> with a <button> element.
* The onclick guard prevents double submissions while the form processes.
*
* @param string $button Default button HTML.
* @param array $form Gravity Forms form array.
* @return string
*/
function scseed_gf_custom_submit_button( $button, $form ) {
$label = esc_html( $form['button']['text'] ?? 'Submit' );
$form_id = absint( $form['id'] );
return sprintf(
'<button type="submit" id="gform_submit_button_%1$d" class="gform_button button"'
. ' onclick="if(window['gf_submitting_%1$d']){return false;}'
. ' window['gf_submitting_%1$d']=true;">'
. '%2$s'
. '</button>',
$form_id,
$label
);
}
add_filter( 'gform_submit_button', 'scseed_gf_custom_submit_button', 10, 2 );
}#customization#forms#gravity-forms#submit-button#ux