Making Forms Bootstrap Compatible

In this example, we will make all TML forms Bootstrap compatible.

function make_tml_forms_bootstrap_compatible() {
	foreach ( tml_get_forms() as $form ) {
		foreach ( tml_get_form_fields( $form ) as $field ) {
			if ( 'hidden' == $field->get_type() ) {
				continue;
			}

			$field->render_args['before'] = '<div class="form-group">';
			$field->render_args['after'] = '</div>';
			if ( 'checkbox' != $field->get_type() ) {
				$field->add_class( 'form-control' );
			}
		}
	}
}
add_action( 'init', 'make_tml_forms_bootstrap_compatible' );