/**
* Filters the next, previous and submit buttons.
* Replaces the form's <input> buttons with <button> while maintaining attributes from original <input>.
*
* @param string $button Contains the <input> tag to be filtered.
* @param object $form Contains all the properties of the current form.
*
* @return string The filtered button.
*/
add_filter('gform_submit_button', 'input_to_button', 10, 2);
function input_to_button($button, $form)
{
$dom = new DOMDocument();
$dom->loadHTML('<?xml encoding="utf-8" ?>' . $button);
$input = $dom->getElementsByTagName('input')->item(0);
$new_button = $dom->createElement('button');
$new_button->appendChild($dom->createTextNode($input->getAttribute('value')));
$input->removeAttribute('value');
foreach ($input->attributes as $attribute) {
$new_button->setAttribute($attribute->name, $attribute->value);
}
$classes = $new_button->getAttribute('class');
$classes .= " btn is-style-with-arrow";
$new_button->setAttribute('class', $classes);
$input->parentNode->replaceChild($new_button, $input);
return $dom->saveHtml($new_button);
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter