Commit 0881fdb6 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

Taking into accound CharFieldDataList

parent 2db67b7e
......@@ -3,6 +3,7 @@ import logging
from django import forms
from django import template
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext
register = template.Library()
logger = logging.getLogger(__name__)
......@@ -55,10 +56,25 @@ def bootstrap(object):
# overwrite the css classes
attrs["class"] = " ".join(css_classes)
if 'datalist' in attrs:
datalist = attrs.pop("datalist")
attrs["list"] = "list__%s" % field.id_for_label
datalist = None
# render the field
ret.append('<div class="%s">' % wrapping_classes)
ret.append("""<label class="%s">%s</label>""" % (label_classes, field.label))
# If the field has a datalist attribut the input field will suggest from it, printing the element
if datalist:
ret.append('<datalist id="%s">' % attrs["list"])
for option in datalist:
ret.append('<option value="%s">' % option)
if help_text:
ret.append("""<small class ="form-text text-muted">%s</small>""" % help_text)
if field.errors:
......@@ -69,7 +85,6 @@ def bootstrap(object):
# return it as safe html code
elif isinstance(object, forms.BaseFormSet):
formset = object
for error in formset.non_form_errors():
ret.append("""<div class="alert alert-danger">%s</div>""" % error.replace("\n", "<br/>"))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment