def get_fields_for_formset(formset, fields):
    """
    Utility method to grab fields that should be displayed for a FormSet
    """
    if fields is None:
        return formset.empty_form.visible_fields()
    else:
        return [
            f for f in formset.empty_form.visible_fields() \
                if f.name in fields.split(',')
        ]