Open captain828 opened 8 months ago
I'm unable to reproduce this. It's working fine in the playground.
You can also test your schema in the playground (be sure to make it valid json i.e. use double quotes instead of single).
Also, which version are you using. Find out using this command:
$ python -c "import django_jsonform; print(django_jsonform.__version__)"
Hhhm, it does work on the playground and also if I give it a schema on the model field but not via Javascript, using
form.update({
schema: schema,
data: form.getData()
});
The actual schema I am sending is:
{
"default": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
"items": {
"enum": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
"type": "string",
"widget": "multiselect"
},
"type": "array"
}
(generated from a Pydantic model)
All other defaults are working fine.
This might be a bug or it might be the expected behaviour.
I don't think the form will populate the defaults on updates.
E.g. let's say a user has de-selected the defaults from the input, and so later on when update()
is called, the form should keep the array empty instead of re-populating the defaults because the user had already edited the input and removed them.
Though I'm not exactly sure if this is what's really going on.
If you could provide me exact code to reproduce this, I will be conclusively able to tell whether it is a bug or not.
Is there a way to define defaults for an array?
I've tried:
but it's not working.