diff --git a/bread/views/util.py b/bread/views/util.py index c6946e08..71fa98a9 100644 --- a/bread/views/util.py +++ b/bread/views/util.py @@ -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): @@ -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(