From 1fd37c16312cbde29001b4d2d09467212b3a669a Mon Sep 17 00:00:00 2001 From: Enric Caumons Date: Tue, 10 Sep 2013 01:50:41 +0200 Subject: [PATCH 1/2] Improvements for Bootstrap 3.0 support. Includes: - Fixed problem with inputs of type file, that were displayed inside an input text element - Added support for Django Form `required_css_class` and `error_css_class` - Added CSS class `multiple-checkbox`, to be used to easily hide `
  • ` elements in multiple checkboxes from your styles file --- .../templates/bootstrapform/field.html | 19 +++++++++---------- bootstrapform/templatetags/bootstrap.py | 8 +++++++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/bootstrapform/templates/bootstrapform/field.html b/bootstrapform/templates/bootstrapform/field.html index e59fa6e..dc936e5 100644 --- a/bootstrapform/templates/bootstrapform/field.html +++ b/bootstrapform/templates/bootstrapform/field.html @@ -4,12 +4,12 @@ {% if field|is_checkbox %}
    -
    - {% else %}{% if field|is_radio %} - + {% elif field|is_radio %} +
    {% for choice in field %} @@ -33,7 +33,7 @@ {% endfor %} {% for error in field.errors %} - {{ error }} + {{ error }} {% endfor %} {% if field.help_text %} @@ -42,15 +42,14 @@

    {% endif %}
    - {% else %} - + -
    +
    {{ field }} {% for error in field.errors %} - {{ error }} + {{ error }} {% endfor %} {% if field.help_text %} @@ -59,5 +58,5 @@

    {% endif %}
    - {% endif %}{% endif %} + {% endif %}
    diff --git a/bootstrapform/templatetags/bootstrap.py b/bootstrapform/templatetags/bootstrap.py index 3ab5aac..8f81796 100644 --- a/bootstrapform/templatetags/bootstrap.py +++ b/bootstrapform/templatetags/bootstrap.py @@ -48,7 +48,8 @@ def bootstrap_horizontal(element, label_cols={}): def add_input_classes(field): - if not is_checkbox(field) and not is_multiple_checkbox(field) and not is_radio(field): + if not is_checkbox(field) and not is_multiple_checkbox(field) and not is_radio(field) \ + and not is_file(field): field_classes = field.field.widget.attrs.get('class', '') field_classes += ' form-control' field.field.widget.attrs['class'] = field_classes @@ -93,3 +94,8 @@ def is_multiple_checkbox(field): @register.filter def is_radio(field): return field.field.widget.__class__.__name__.lower() == "radioselect" + + +@register.filter +def is_file(field): + return field.field.widget.__class__.__name__.lower() == "clearablefileinput" From aee2b719b27498f1b3dcbb1909a8443ff6d1cf9f Mon Sep 17 00:00:00 2001 From: Enric Caumons Date: Thu, 26 Sep 2013 12:02:56 +0200 Subject: [PATCH 2/2] added some build created dirs to .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 7ef72bb..e26e110 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ *.pyc .DS_Store docs/_build +build/ +dist/ +django_bootstrap_form.egg-info/ +