Skip to content

Commit

Permalink
raise error if form is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
bendavis78 committed Jan 27, 2012
1 parent 37311fb commit bfebab6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions formhelper/templatetags/formhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def render(self, context):
form = self.form.resolve(context)
except template.VariableDoesNotExist:
raise template.TemplateSyntaxError('a form must either be passed to form_field as first argument or must exist in context as "form"')
if not form:
raise template.TemplateSyntaxError('form is empty')
tpl = get_template('formhelper/includes/field.html')
field = _get_field(self.field, form, context)
return tpl.render(template.Context({'form':form, 'field':field}))
Expand Down

0 comments on commit bfebab6

Please sign in to comment.