Skip to content

Commit

Permalink
Added set support for arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
xshiki committed Dec 11, 2024
1 parent 60fa129 commit 384af3a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ipywidgets_jsonschema/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,12 +931,19 @@ def _resetter():
# Initially call the resetter
_resetter()

def _getter():
result = [h.getter() for h in elements[:element_size]]
if schema.get("set", False):
if len(result) != len(set(result)):
raise FormError("Array elements are not unique")
return result

wrapped_vbox[0] = self._wrap_description(
wrapped_vbox[0], schema.get("description", None)
)

return self.construct_element(
getter=lambda: [h.getter() for h in elements[:element_size]],
getter=_getter,
setter=_setter,
resetter=_resetter,
widgets=wrapped_vbox,
Expand Down

0 comments on commit 384af3a

Please sign in to comment.