Return to Snippet

Revision: 46120
at May 13, 2011 03:51 by tclancy


Initial Code
def __init__(self, *args, **kwargs):
        super(form, self).__init__(*args, **kwargs)
        for field in self.errors:
            if not field == '__all__': 
                # errors dict can have key __all__ for non field errors.
                self.fields[field].widget.attrs['class'] = \
                    self.fields[field].widget.attrs.get('class', '') + 'error'

Initial URL
http://stackoverflow.com/questions/5339288/rendering-required-and-error-classes-with-django-form-fields-in-a-custom-templat

Initial Description

                                

Initial Title
Add Class to All Error Fields in Form

Initial Tags

                                

Initial Language
Python