Skip to content

Commit

Permalink
Merge pull request #42 from cre8r/master
Browse files Browse the repository at this point in the history
Fixed form errors (non_field_errors) not being displayed
  • Loading branch information
earle committed Mar 12, 2012
2 parents 8e432d0 + dcff226 commit cea85ef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bootstrap/forms.py
Expand Up @@ -10,11 +10,6 @@ class NoSuchFormField(Exception):
"""""The form field couldn't be resolved."""""
pass

def error_list(errors):
return '<ul class="errors"><li>' + \
'</li><li>'.join(errors) + \
'</li></ul>'

class BootstrapMixin(object):

def __bootstrap__(self):
Expand All @@ -35,16 +30,21 @@ def __bootstrap__(self):
else:
self.template_base = "bootstrap"

def top_errors_as_html(self):
""" Render top errors as set of <div>'s. """
return ''.join(["<div class=\"alert alert-error\">%s</div>" % error
for error in self.top_errors])

def as_div(self):
""" Render the form as a set of <div>s. """

self.top_errors = []
self.top_errors = self.non_field_errors()
self.prefix_fields = []

output = self.render_fields(self.layout)

if self.top_errors:
errors = error_list(self.top_errors)
errors = self.top_errors_as_html()
else:
errors = u''

Expand Down

0 comments on commit cea85ef

Please sign in to comment.