Last active
October 4, 2018 14:44
-
-
Save BramEsposito/567c8094cd960475f2a2a1c9e1ca09b8 to your computer and use it in GitHub Desktop.
theme gravity forms with bootstrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ADD THIS TO THE functions.php file OF YOUR (CHILD) THEME | |
// apply to all forms | |
add_filter( 'gform_field_content', function ( $field_content, $field ) { | |
if ($field->type == "name") { | |
$field_content = preg_replace( '(<input)', '<input class="form-control" ', $field_content ); | |
} else { | |
$field_content = preg_replace( '(<input .*class=\')', '$0form-control ', $field_content ); | |
$field_content = preg_replace( '(<select .*class=\')', '$0form-control ', $field_content ); | |
$field_content = preg_replace( '(<textarea .*class=\')', '$0form-control ', $field_content ); | |
} | |
return $field_content; | |
}, 10, 2 ); | |
add_filter( 'gform_submit_button', function ( $button, $form ) { | |
$button = preg_replace( '(<input .*class=\')', '$0btn btn-primary form-control ', $button ); | |
return $button; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment