django-bootstrap-form icon indicating copy to clipboard operation
django-bootstrap-form copied to clipboard

Set size on all / individual fields

Open AaronPresley opened this issue 12 years ago • 1 comments

Love this! Thanks for writing it. Quick thought:

It would be nice to be able to set the size when displaying the fields (either for all or individual). I believe the 2.x syntax is by adding a "span[x]" class to the input element.

http://twitter.github.com/bootstrap/base-css.html#forms

Thanks again!

AaronPresley avatar Apr 07 '12 02:04 AaronPresley

The way I have been implementing it is by overriding the init method of my form

def __init__(self, *args, **kwargs):
    super(MyForm, self).__init__(*args, **kwargs)
    classes = {
        'title': 'span12',
        'description': 'span12',
        'picture': 'span5',
    }
    for field, css in classes.items():
        if field in self.fields: 
            self.fields[field].widget.attrs['class'] = css

esquevin avatar Jun 08 '12 09:06 esquevin