Change Gravity Forms Submit to Button

Don’t use the method provided in Gravity Forms documentation as it strips out important attributes.

 * Change submit from input to button
 * Do not use example provided by Gravity Forms as it strips out the button attributes including onClick
function wd_gf_update_submit_button( $button_input, $form ) {

     //save attribute string to $button_match[1]
     preg_match( "/<input([^\/>]*)(\s\/)*>/", $button_input, $button_match );

     //remove value attribute (since we aren't using an input)
     $button_atts = str_replace( "value='" . $form['button']['text'] . "' ", "", $button_match[1] );

     // create the button element with the button text inside the button element instead of set as the value
     return '<button ' . $button_atts . '><span>' . $form['button']['text'] . '</span></button>';

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

About Matt Whiteley

Matt has been building bespoke WordPress websites for over 10 years specializing in the Genesis Framework. He integrates Advanced Custom Fields heavily in all builds, especially with the new Gutenberg Block Editor, allowing clients to easily modify all aspects of the their website with ease.

He works with a wide variety of small businesses and agencies across the country providing development services as well as hosting and maintenance. When he isn't coding he enjoys spending time with his wife and two children, golfing and playing poker.