From 384af3a2b432a6676b4dc2e88c915c3149acc8cc Mon Sep 17 00:00:00 2001 From: Shiki <64834708+xshiki@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:05:08 +0100 Subject: [PATCH] Added set support for arrays --- ipywidgets_jsonschema/form.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ipywidgets_jsonschema/form.py b/ipywidgets_jsonschema/form.py index fdf4a9f..9d2de37 100644 --- a/ipywidgets_jsonschema/form.py +++ b/ipywidgets_jsonschema/form.py @@ -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,