def collapse_form(form, category):
    """ Permit to return the class of the collapsible according to errors in
    the form. """
    categories_with_error = set()
    for field in form:
        if field.errors:
            categories_with_error.add(field.field.widget.attrs['category'])
    if category.name in categories_with_error:
        return 'in'
    return ''
