From 20a8009562b4d03b334469fbe2902386be3371f4 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 18 Oct 2023 12:48:05 +0200 Subject: 🐛 Custom forms: fix crash when removing fields already filtered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/forms.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ishtar_common/forms.py') diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index b0bf64b46..0f1263bef 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -195,6 +195,16 @@ class CustomForm(BSForm): if not self._explicit_ordering: self.custom_form_ordering() + def _remove_fields(self, field_names): + """ + Remove field (if already present) + """ + if not getattr(self, "fields", None): + return + for name in field_names: + if name in self.fields: + self.fields.pop(name) + def custom_form_ordering(self): available, header, excluded, json_fields = self.check_custom_form( self.current_user) -- cgit v1.2.3