mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fixes for 'non field' errors in forms
- Fixes issue where non-model fields would not show error text
This commit is contained in:
parent
aacc7119bd
commit
56f05e2604
@ -28,6 +28,7 @@ class HelperForm(forms.ModelForm):
|
||||
self.helper = FormHelper()
|
||||
|
||||
self.helper.form_tag = False
|
||||
self.helper.form_show_errors = True
|
||||
|
||||
"""
|
||||
Create a default 'layout' for this form.
|
||||
@ -43,11 +44,6 @@ class HelperForm(forms.ModelForm):
|
||||
|
||||
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):
|
||||
|
@ -1,3 +1,5 @@
|
||||
{% load i18n %}
|
||||
|
||||
<div>
|
||||
{% if form.pre_form_info %}
|
||||
<div class='alert alert-info alert-block' role='alert'>
|
||||
@ -9,18 +11,6 @@
|
||||
{{ form.pre_form_warning }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% block non_field_error %}
|
||||
{% if form.non_field_errors %}
|
||||
<div class='alert alert-danger alert-block' role='alert'>
|
||||
<b>Error Submitting Form:</b>
|
||||
<ul>
|
||||
{% for error in form.non_field_errors %}
|
||||
{{ error }}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
||||
{% block pre_form_content %}
|
||||
@ -41,4 +31,4 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block post_form_content %}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user