Skip to content

Instantly share code, notes, and snippets.

@vanbernaert
Last active August 29, 2015 14:17
Show Gist options
  • Save vanbernaert/cfc80b5d702c5d290658 to your computer and use it in GitHub Desktop.
Save vanbernaert/cfc80b5d702c5d290658 to your computer and use it in GitHub Desktop.
Gravity forms, replace <input type="submit> element with a <button> element
// credits: https://github.com/CFXd
function gf_make_submit_input_into_a_button_element($button_input, $form) {
//save attribute string to $button_match[1]
preg_match("/<input([^\/>]*)(\s\/)*>/", $button_input, $button_match);
//remove value attribute
$button_atts = str_replace("value='".$form['button']['text']."' ", "", $button_match[1]);
return '<button '.$button_atts.'>'.$form['button']['text'].'<i class="fa fa-refresh"></i></button>';
}
add_filter('gform_submit_button', 'gf_make_submit_input_into_a_button_element', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment