@@ -86,11 +86,18 @@ def form_valid(self, form):
86
86
get_option (form , render_success ), context .flatten (), self .request
87
87
),
88
88
)
89
- else :
89
+ elif redirect :
90
90
errors , result , redir , content = (
91
91
[],
92
92
"success" ,
93
- redirect or "" ,
93
+ redirect ,
94
+ "" ,
95
+ )
96
+ else :
97
+ errors , result , redir , content = (
98
+ [_ ("No content in response from" )],
99
+ "error" ,
100
+ "" ,
94
101
"" ,
95
102
)
96
103
redirect = redirect or redir
@@ -238,8 +245,8 @@ def render(self, context, instance, placeholder):
238
245
class FormPlugin (CMSAjaxForm ):
239
246
name = _ ("Form" )
240
247
model = models .Form
241
- form = forms .FormsForm
242
248
249
+ # form = forms.FormsForm
243
250
render_template = f"djangocms_form_builder/{ settings .framework } /form.html"
244
251
change_form_template = "djangocms_frontend/admin/base.html"
245
252
allow_children = True
@@ -269,15 +276,17 @@ class FormPlugin(CMSAjaxForm):
269
276
),
270
277
]
271
278
272
- # @classmethod
273
- # def get_parent_classes(cls, slot, page, instance=None): # TODO Should avoid nested forms -> not working
274
- # """Only valid if not inside form"""
275
- # parent = instance
276
- # while parent is not None:
277
- # if parent.plugin_type == FormPlugin.__name__:
278
- # return [""]
279
- # parent = parent.parent
280
- # return super().get_parent_classes(slot, page, instance)
279
+ cache_parent_classes = False
280
+
281
+ @classmethod
282
+ def get_parent_classes (cls , slot , page , instance = None ):
283
+ """Only valid if not inside form"""
284
+ parent = instance
285
+ while parent is not None :
286
+ if parent .plugin_type == FormPlugin .__name__ :
287
+ return ["" ]
288
+ parent = parent .parent
289
+ return super ().get_parent_classes (slot , page , instance )
281
290
282
291
def get_fieldsets (self , request , obj = None ):
283
292
if recaptcha .installed :
@@ -311,28 +320,7 @@ def get_form_class(self, slug=None):
311
320
if self .instance .child_plugin_instances :
312
321
return self .create_form_class_from_plugins ()
313
322
if self .instance .form_selection :
314
- form_class = forms ._form_registry .get (self .instance .form_selection , None )
315
- if form_class :
316
- # add options from form admin - if the form_class does not already set them
317
- additional_options = dict (
318
- floating_labels = self .instance .form_floating_labels ,
319
- field_sep = self .instance .form_spacing ,
320
- login_required = self .instance .form_login_required ,
321
- unique = self .instance .form_unique ,
322
- form_actions = self .instance .form_actions ,
323
- )
324
- if hasattr (form_class , "Meta" ):
325
- options = getattr (
326
- form_class .Meta ,
327
- "_original_options" ,
328
- getattr (form_class .Meta , "options" , {})
329
- )
330
- form_class .Meta ._original_options = options # store original options settings
331
- additional_options .update (options ) # apply them to the form admin's option
332
- form_class .Meta .options = additional_options # use them
333
- else :
334
- form_class .Meta = type ("Meta" , (), dict (options = additional_options ))
335
- return form_class
323
+ return forms ._form_registry .get (self .instance .form_selection , None )
336
324
return None
337
325
338
326
def create_form_class_from_plugins (self ):
0 commit comments