From 80b70fd2df973c941b3fda7825ef1efd31960059 Mon Sep 17 00:00:00 2001 From: eeintech Date: Thu, 12 Nov 2020 16:38:35 -0500 Subject: [PATCH] Fixed disabling of form errors messing-up with global settings --- InvenTree/InvenTree/forms.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/InvenTree/InvenTree/forms.py b/InvenTree/InvenTree/forms.py index 6cc4a9ed5f..4be8a28acb 100644 --- a/InvenTree/InvenTree/forms.py +++ b/InvenTree/InvenTree/forms.py @@ -29,11 +29,6 @@ class HelperForm(forms.ModelForm): self.helper.form_tag = False - # Check for errors from model validation - # If none, disable crispy form errors - if not self.errors: - self.helper.form_show_errors = False - """ Create a default 'layout' for this form. Ref: https://django-crispy-forms.readthedocs.io/en/latest/layouts.html @@ -44,6 +39,17 @@ class HelperForm(forms.ModelForm): self.rebuild_layout() + def is_valid(self): + + valid = super(HelperForm, self).is_valid() + + # Check for errors from model validation + # If none, disable crispy form errors + if not self.errors: + self.helper.form_show_errors = False + + return valid + def rebuild_layout(self): layouts = []