Skip to content

Commit

Permalink
fix: correct error handling and submit-button displaying with/without…
Browse files Browse the repository at this point in the history
… ajax
  • Loading branch information
saemideluxe committed Sep 1, 2021
1 parent 748965b commit b673f30
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bread/views/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ def get_layout(self):
else:
ret.append(field)

if self.ajax_urlparameter in self.request.GET:
return hg.BaseElement(
hg.H3(self.object), breadlayout.form.Form(hg.C("form"), ret)
)
# wrap with form will add a submit button
return hg.BaseElement(
hg.H3(self.object), breadlayout.form.Form(hg.C("form"), ret)
hg.H3(self.object), breadlayout.form.Form.wrap_with_form(hg.C("form"), ret)
)

def get_form(self, form_class=None):
Expand All @@ -68,7 +73,7 @@ def get_form(self, form_class=None):
attrs=form.fields[fieldelement.fieldname].widget.attrs
)
else:
if form.errors:
if form.errors and self.ajax_urlparameter not in self.request.GET:
messages.error(
self.request,
mark_safe(
Expand Down

0 comments on commit b673f30

Please sign in to comment.