mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #30261 -- Prevented Form._html_output() from mutating errors if hidden fields have errors.
This commit is contained in:
committed by
Mariusz Felisiak
parent
da4923ea87
commit
49275c5488
@@ -191,7 +191,8 @@ class BaseForm:
|
||||
|
||||
def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row):
|
||||
"Output HTML. Used by as_table(), as_ul(), as_p()."
|
||||
top_errors = self.non_field_errors() # Errors that should be displayed above all fields.
|
||||
# Errors that should be displayed above all fields.
|
||||
top_errors = self.non_field_errors().copy()
|
||||
output, hidden_fields = [], []
|
||||
|
||||
for name, field in self.fields.items():
|
||||
|
||||
@@ -92,6 +92,11 @@ class ErrorList(UserList, list):
|
||||
def as_data(self):
|
||||
return ValidationError(self.data).error_list
|
||||
|
||||
def copy(self):
|
||||
copy = super().copy()
|
||||
copy.error_class = self.error_class
|
||||
return copy
|
||||
|
||||
def get_json_data(self, escape_html=False):
|
||||
errors = []
|
||||
for error in self.as_data():
|
||||
|
||||
Reference in New Issue
Block a user