Skip to content

Commit

Permalink
Merge pull request #11 from ssciwr/checkbox-fixup
Browse files Browse the repository at this point in the history
[bugfix] Do not use pop on schema dictionaries
  • Loading branch information
dokempf authored Feb 3, 2022
2 parents 93ce458 + 29c7762 commit e3556a4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ipywidgets_jsonschema/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,18 @@ def _construct_integer(self, schema, label=None, root=False):
return self._construct_simple(schema, ipywidgets.IntText(), label=label)

def _construct_boolean(self, schema, label=None, root=False):
if "title" not in schema:
raise FormError("Fields of boolean type need to specify title")
title = schema.pop("title")
# Extract the labelling for the checkbox
title = schema.get("title", label)

if title is None:
raise FormError(
"Fields of boolean type need to specify title or be part of a mapping"
)

return self._construct_simple(
schema, ipywidgets.Checkbox(indent=False, description=title), label=None
{k: v for k, v in schema.items() if k != "title"},
ipywidgets.Checkbox(indent=False, description=title),
label=None,
)

def _construct_null(self, schema, label=None, root=False):
Expand Down

0 comments on commit e3556a4

Please sign in to comment.