Skip to content

Instantly share code, notes, and snippets.

@cameronjonesweb
Created October 4, 2018 06:17
Show Gist options
  • Save cameronjonesweb/09d0c756e08bb62ce9bba4ba5e84e38a to your computer and use it in GitHub Desktop.
Save cameronjonesweb/09d0c756e08bb62ce9bba4ba5e84e38a to your computer and use it in GitHub Desktop.
Adds a class that defines the type of field to the <li> element in Gravity Forms
<?php
add_filter( 'gform_field_css_class', 'cameronjonesweb_add_field_type_to_class', 10, 3 );
/**
* Adds a class that defines the type of field to the li element in Gravity Forms
*
* @param string $css_class The existing CSS classes.
* @param GF_Field $field The field object.
* @param array $form The form object.
* @return string
*/
function cameronjonesweb_add_field_type_to_class( $css_class, $field, $form ) {
$css_class .= ' gfield--' . $field->type;
return $css_class;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment