Skip to content

Commit 5e52f76

Browse files
khangoncweitat
andauthored
feature-8782: Add type Yes/No custom from field (#8893)
* fix-8782: Add type Yes/No custom from field * feature-8782: Update code add type YesNo for custom form * feature-8782:update code add type Yes/No custom from field * Update custom_forms.py --------- Co-authored-by: cweitat <[email protected]>
1 parent 6ce3b8d commit 5e52f76

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

app/api/helpers/custom_forms.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def get_schema(form_fields):
2121
field_type = TrimmedEmail
2222
elif field.type == 'number':
2323
field_type = marshmallow.fields.Float
24+
elif field.type == 'boolean':
25+
field_type = marshmallow.fields.Boolean
2426
else:
2527
raise UnprocessableEntityError(
2628
{'pointer': '/data/complex-field-values/' + field.identifier},
@@ -45,7 +47,10 @@ def validate_custom_form_constraints(form, obj, excluded):
4547
if not getattr(obj, field.identifier):
4648
missing_required_fields.append(field.identifier)
4749
else:
48-
if not (obj.complex_field_values or {}).get(field.identifier):
50+
if obj.complex_field_values:
51+
if obj.complex_field_values.get(field.identifier) is None:
52+
missing_required_fields.append(field.identifier)
53+
else:
4954
missing_required_fields.append(field.identifier)
5055

5156
if len(missing_required_fields) > 0:

app/api/schema/custom_forms.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Meta:
4040
"email",
4141
"number",
4242
"paragraph",
43+
"boolean",
4344
"year",
4445
]
4546
),

0 commit comments

Comments
 (0)