Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added proper checkbox and radio button render

  • Loading branch information...
commit f48c517a9647edcbfe92ce8ec7cd3f3f718559bf 1 parent 8fad598
@dfryta dfryta authored
View
17 django_common/templates/common/fragments/checkbox_field.html
@@ -0,0 +1,17 @@
+<div id="id_{{ form_field.html_name }}_container" class="control-group formRow clearfix {% if css_classes %}{{ css_classes }}{% endif %} {% if form_field.errors %}error{% endif %}">
+ <div class="input">
+ <label class="checkbox">
+ {{ form_field }}
+ {{ form_field.label }}
+
+ {% if help_text %}
+ <span class="help-inline">{{ help_text }}</span>
+ {% endif %}
+
+ {% if form_field.errors %}
+ <span class="help-inline">{{ form_field.errors }}</span>
+ {% endif %}
+
+ </label>
+ </div>
+</div>
View
8 ...plates/common/fragments/radio_checkbox_field.html → ...ommon/templates/common/fragments/radio_field.html
@@ -1,7 +1,9 @@
<div id="id_{{ form_field.html_name }}_container" class="control-group formRow clearfix {% if css_classes %}{{ css_classes }}{% endif %} {% if form_field.errors %}error{% endif %}">
- {{ form_field.label_tag }}
+ <div class="input">
+ <label class="radio">
+ {{ form_field }}
+ {{ form_field.label }}
- <div class="input">{{ form_field }}
{% if help_text %}
<span class="help-inline">{{ help_text }}</span>
{% endif %}
@@ -9,5 +11,7 @@
{% if form_field.errors %}
<span class="help-inline">{{ form_field.errors }}</span>
{% endif %}
+
+ </label>
</div>
</div>
View
7 django_common/templatetags/custom_tags.py
@@ -24,10 +24,11 @@ def render(self, context):
return ''
widget = form_field.field.widget
-
- if isinstance(widget, widgets.RadioSelect) or isinstance(widget, widgets.CheckboxSelectMultiple)\
+ if isinstance(widget, widgets.CheckboxSelectMultiple)\
or isinstance(widget, widgets.CheckboxInput):
- t = get_template('common/fragments/radio_checkbox_field.html')
+ t = get_template('common/fragments/checkbox_field.html')
+ elif isinstance(widget, widgets.RadioSelect):
+ t = get_template('common/fragments/radio_field.html')
else:
t = get_template('common/fragments/form_field.html')
return t.render(Context({
Please sign in to comment.
Something went wrong with that request. Please try again.