Question form: Do not show "This field is required" twice

This commit is contained in:
Raphael Michel
2021-01-12 12:55:24 +01:00
parent a8cbb06bb0
commit 4e870b7366

View File

@@ -690,8 +690,9 @@ class BaseQuestionsForm(forms.Form):
if not self.all_optional:
for q in question_cache.values():
answer = d.get('question_%d' % q.pk)
if question_is_required(q) and not answer and answer != 0:
raise ValidationError({'question_%d' % q.pk: [_('This field is required')]})
field = self['question_%d' % q.pk]
if question_is_required(q) and not answer and answer != 0 and not field.errors:
raise ValidationError({'question_%d' % q.pk: [_('This field is required.')]})
return d