Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add inputName as class to hidden fields and inputs for Gravityforms
add_filter( 'gform_field_css_class', 'hidden_field_css_class', 10, 3 );
function hidden_field_css_class( $classes, $field, $form ) {
if( $field->type == 'hidden' ){
$classes .= ' '.$field->inputName;
}
return $classes;
}
// Add inputName as class to hidden fields
add_filter( 'gform_field_input', 'hidden_field_input', 10, 5 );
function hidden_field_input( $input, $field, $value, $lead_id, $form_id ){
if( $field->type == 'hidden' ){
$input = '<input name="input_'.$field->id.'" id="input_'.$form_id.'_'.$field->id.'" type="hidden" class="gform_hidden '.$field->inputName.'" aria-invalid="false" value="">';
}
return $input;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.