Addition to Jay Hoffmann's 'add_bootstrap_container_class' filter for Gravity Forms, replacing size classes with columns
<?php | |
/** | |
* @description Gravity Forms size overides using Bootstrap Columns | |
* | |
* @author Jay Hoffmann (modified by Ryan Edwards) | |
* | |
* @source https://jayhoffmann.com/using-gravity-forms-bootstrap-styles/ | |
*/ | |
add_filter( 'gform_field_container', 'add_bootstrap_container_class', 10, 6 ); | |
function add_bootstrap_container_class( $field_container, $field, $form, $css_class, $style, $field_content ) { | |
$id = $field->id; | |
$field_id = is_admin() || empty( $form ) ? "field_{$id}" : 'field_' . $form['id'] . "_$id"; | |
switch ( $field->size ) { | |
case 'medium': | |
$col = 'col-8'; | |
break; | |
case 'small': | |
$col = 'col-4'; | |
break; | |
default: | |
$col = 'col'; | |
break; | |
} | |
if ( is_admin() ) { | |
return $field_container; | |
} else { | |
return '<li id="' . $field_id . '" class="' . $col . '">{FIELD_CONTENT}</li>'; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment