Last active
May 16, 2022 18:53
-
-
Save RadGH/aedfc2e143528bcc078d1d4ff923ac79 to your computer and use it in GitHub Desktop.
Gravity Forms: Add field type class to every gfield
This file contains hidden or 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 | |
// Make every gravity form field add its input type as a class. | |
// Example (added class: gfield-type-radio): | |
// fieldset id="field_136_31" class="gfield gfield-type-radio ..." | |
// Some other types: name, email, html, select, ... | |
function aa_add_input_type_gravity_forms( $form ) { | |
foreach ( $form['fields'] as $field ) { | |
if ( $field instanceof GF_Field ) { | |
$field->cssClass .= 'gfield-type-' . $field->get_input_type(); | |
} | |
} | |
return $form; | |
} | |
add_filter( 'gform_pre_render', 'aa_add_input_type_gravity_forms' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment