django-bootstrap-form
django-bootstrap-form copied to clipboard
Set size on all / individual fields
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!
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