Skip to content
Snippets Groups Projects
Commit 7be9aec0 authored by Julian's avatar Julian
Browse files

Use correct options for different types of select fields

parent d2476d59
No related branches found
No related tags found
No related merge requests found
...@@ -132,21 +132,25 @@ class JSONSchema: ...@@ -132,21 +132,25 @@ class JSONSchema:
case forms.CheckboxInput: case forms.CheckboxInput:
new_field["type"] = "boolean" new_field["type"] = "boolean"
case forms.Select: case forms.Select | forms.SelectMultiple | forms.RadioSelect | forms.CheckboxSelectMultiple, forms.NullBooleanSelect:
new_field["type"] = "string" one_of = []
new_field["enum"] = [] # Fixme: load data from widget.options(…) for const, title in field.widget.choices:
one_of.append(dict(const=str(const), title=str(title)))
case forms.NullBooleanSelect:
... if field.widget.allow_multiple_selected:
new_field["type"] = "array"
case forms.SelectMultiple: new_field["items"] = {
... "type": "string",
"oneOf": one_of
case forms.RadioSelect: }
... else:
new_field["type"] = "string"
case forms.CheckboxSelectMultiple: new_field["oneOf"] = one_of
...
if type(field.widget) == forms.RadioSelect:
new_field["x-display"] = "radio"
elif type(field.widget) == forms.CheckboxSelectMultiple:
new_field["x-display"] = "checkbox"
case forms.SplitDateTimeWidget: case forms.SplitDateTimeWidget:
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment