mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-29 17:36:49 +01:00
Remove special case removing FieldPanels from PanelGroup if they're excluded from the form
The is_shown method on FieldPanel now detects this case instead.
This commit is contained in:
parent
470d39e1fe
commit
fae68ad8c8
@ -416,17 +416,7 @@ class PanelGroup(Panel):
|
||||
self.children = [child.bind_to(request=self.request) for child in self.children]
|
||||
|
||||
def on_form_bound(self):
|
||||
children = []
|
||||
for child in self.children:
|
||||
if isinstance(child, FieldPanel):
|
||||
if self.form._meta.exclude:
|
||||
if child.field_name in self.form._meta.exclude:
|
||||
continue
|
||||
if self.form._meta.fields:
|
||||
if child.field_name not in self.form._meta.fields:
|
||||
continue
|
||||
children.append(child.bind_to(form=self.form))
|
||||
self.children = children
|
||||
self.children = [child.bind_to(form=self.form) for child in self.children]
|
||||
|
||||
def render(self):
|
||||
return mark_safe(render_to_string(self.template, {"self": self}))
|
||||
@ -599,6 +589,10 @@ class FieldPanel(Panel):
|
||||
return opts
|
||||
|
||||
def is_shown(self):
|
||||
if self.form is not None and self.bound_field is None:
|
||||
# this field is missing from the form
|
||||
return False
|
||||
|
||||
if (
|
||||
self.permission
|
||||
and self.request
|
||||
@ -722,6 +716,7 @@ class FieldPanel(Panel):
|
||||
try:
|
||||
self.bound_field = self.form[self.field_name]
|
||||
except KeyError:
|
||||
self.bound_field = None
|
||||
return
|
||||
|
||||
if self.heading:
|
||||
|
Loading…
Reference in New Issue
Block a user