spivurno
3/13/2015 - 3:08 PM

Gravity forms, replace <input type="submit> element with a <button> element

Gravity forms, replace <input type="submit> element with a 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);