Ticket #3515: fields.diff

File fields.diff, 905 bytes (added by Simon Litchfield <simon@…>, 12 years ago)

Diff for newforms/fields.py

  • fields.py

     
    3535    # Tracks each time a Field instance is created. Used to retain order.
    3636    creation_counter = 0
    3737
    38     def __init__(self, required=True, widget=None, label=None, initial=None, help_text=None):
     38    def __init__(self, required=True, widget=None, label=None, initial=None, help_text=None, css=None):
    3939        # required -- Boolean that specifies whether the field is required.
    4040        #             True by default.
    4141        # widget -- A Widget class, or instance of a Widget class, that should be
     
    6060        extra_attrs = self.widget_attrs(widget)
    6161        if extra_attrs:
    6262            widget.attrs.update(extra_attrs)
     63
     64        # Allow a CSS class to be specified
     65        if css:
     66            widget.attrs.update({'class':css})
    6367
    6468        self.widget = widget
Back to Top