Skip to content

Commit fd59868

Browse files
author
Dylan Verheul
committed
Added BootstrapDateInput and bootstrap field attributes
1 parent 60b37cf commit fd59868

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ Thanks
6262
* to Twitter for building and releasing Bootstrap
6363
* to the Django community for Django
6464
* to the authors of django-bootstrap-form for the inspiration
65-
* to Stefan Petre
65+
* to Stefan Petre for the datepicker
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{% spaceless %}
2-
{% if prepend %}
3-
<div class="input-prepend"><span class="add-on">{{ prepend }}</span>{{ field }}</div>
4-
{% else %}
5-
{% if append %}
6-
<div class="input-append">{{ field }}<span class="add-on">{{ append }}</span></div>
2+
{% comment %}
3+
Spaceless is required here to make sure prepend and append work properly
4+
{% endcomment %}
5+
{% with prepend=prepend|default:field.field.widget.bootstrap.prepend append=append|default:field.field.widget.bootstrap.append %}
6+
{% if prepend %}
7+
<div class="input-prepend"><span class="add-on">{{ prepend }}</span>{{ field }}</div>
78
{% else %}
8-
{{ field }}
9+
{% if append %}
10+
<div class="input-append">{{ field }}<span class="add-on">{{ append }}</span></div>
11+
{% else %}
12+
{{ field }}
13+
{% endif %}
914
{% endif %}
10-
{% endif %}
11-
{% endspaceless %}
15+
{% endwith %}
16+
{% endspaceless %}

bootstrap_toolkit/widgets.py

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ def add_to_css_class(classes, new_class):
2121

2222
class BootstrapDateInput(forms.TextInput):
2323

24+
bootstrap = {
25+
'append': mark_safe('<i class="icon-th"></i>'),
26+
'prepend': None,
27+
}
28+
2429
class Media:
2530
js = (
2631
settings.STATIC_URL + 'datepicker/js/bootstrap-datepicker.js',

0 commit comments

Comments
 (0)