Skip to content

Instantly share code, notes, and snippets.

@fjarrett
Last active September 22, 2017 21:48
Show Gist options
  • Save fjarrett/8259070 to your computer and use it in GitHub Desktop.
Save fjarrett/8259070 to your computer and use it in GitHub Desktop.
<?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
Copy link

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