from django import template

register = template.Library()


@register.filter(name="add_class")
def add_class(field, css_class):
    # If the widget is CheckboxInput, skip adding 'form-control'
    if field.field.widget.__class__.__name__ == "CheckboxInput":
        return field.as_widget()
    return field.as_widget(attrs={"class": css_class})
