diff options
| author | 2020-12-28 14:28:21 +0200 | |
|---|---|---|
| committer | 2020-12-28 14:28:21 +0200 | |
| commit | 964e0757d5a070483bb75e1bcad48aff099e986b (patch) | |
| tree | 67c2ca29e0a709facd18fa18cb1d7714b72f24b0 /backend | |
| parent | Add required field to question model (diff) | |
Add handling of optional fields to submit endpoint
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/routes/forms/submit.py | 5 | 
1 files changed, 4 insertions, 1 deletions
| diff --git a/backend/routes/forms/submit.py b/backend/routes/forms/submit.py index 8588a2d..d8e6d35 100644 --- a/backend/routes/forms/submit.py +++ b/backend/routes/forms/submit.py @@ -111,7 +111,10 @@ class SubmitForm(Route):              missing_fields = []              for question in form.questions:                  if question.id not in response["response"]: -                    missing_fields.append(question.id) +                    if not question.required: +                        response["response"][question.id] = None +                    else: +                        missing_fields.append(question.id)              if missing_fields:                  return JSONResponse({ | 
