Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Override the output of the submit button on forms, useful for
* adding custom classes or other attributes.
*
* @param string $button An HTML string of the default button
* @param array $form An array of form data
* @return string $button
*
* @filter gform_submit_button
*/
function fjarrett_gform_submit_button( $button, $form ) {
$button = sprintf(
'<input type="submit" class="my-custom-class" id="gform_submit_button_%d" value="%s">',
absint( $form['id'] ),
esc_attr( $form['button']['text'] )
);
return $button;
}
add_filter( 'gform_submit_button', 'fjarrett_gform_submit_button', 10, 2 );
@jorgept

This comment has been minimized.

Copy link

@jorgept jorgept commented Sep 22, 2017

Great!
And add classes for text input fields?
Normal is the"length" of the field, medium, small, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment