Skip to content

Commit

Permalink
Merge pull request #50 from ssciwr/array-defaults
Browse files Browse the repository at this point in the history
Allow defaults on arrays
dokempf authored Sep 9, 2022
2 parents f1cb869 + 05e51d6 commit 0cd40a3
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ipywidgets_jsonschema/form.py
Original file line number Diff line number Diff line change
@@ -603,6 +603,9 @@ def _resetter():
if "default" in schema:
_setter(schema["default"])

# Initially call the resetter
_resetter()

return self.construct_element(
getter=lambda: [h.getter() for h in elements[:element_size]],
setter=_setter,
16 changes: 16 additions & 0 deletions tests/schemas/array-defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"default": [
"foo",
"bar"
],
"schema": {
"default": [
"foo",
"bar"
],
"items": {
"type": "string"
},
"type": "array"
}
}

0 comments on commit 0cd40a3

Please sign in to comment.