Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When initial form data is empty, the widget doesn't create the expected data structure #130

Closed
ooppsss60 opened this issue Nov 13, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@ooppsss60
Copy link

ooppsss60 commented Nov 13, 2023

I have this schema:
{ "type": "array", "items": { "anyOf": [ { "title": "Text", "type": "object", "keys": { "name": { "type": "string" }, "type": { "const": "text", }, "value": { "type": "string" } } }, { "title": "Tags", "type": "object", "keys": { "name": { "type": "string" }, "type": { "const": "tags" }, "value": { "type": "array", "items": { "type": "string" }, "minItems": 1 } } } ] }, "minItems": 1, "maxItems": 10 }

Property 'type' has no value in my form:

image

This causes an error: 'Some required fields are missing'

@bhch
Copy link
Owner

bhch commented Nov 13, 2023

I just tested your given schema in the playground. It is working as expected.

{
    "type": "array",
    "items": {
        "anyOf": [
            {
                "title": "Text",
                "type": "object",
                "keys": {
                    "name": {"type": "string"},
                    "type": {"const": "text"},
                    "value": {"type": "string"}
                } 
            },
            {
                "title": "Tags",
                "type": "object",
                "keys": {
                    "name": {"type": "string"},
                    "type": {"const": "tags"},
                    "value": {
                        "type": "array",
                        "items": {"type": "string"},
                        "minItems": 1
                    }
                }
            }
        ]
    },
    "minItems": 1,
    "maxItems": 10
}

@ooppsss60
Copy link
Author

In playground, it works perfect, but in Django admin not(
I use python3.9, Django 4.2.7

@bhch
Copy link
Owner

bhch commented Nov 13, 2023

EDIT:

Sorry, ignore my previous comment. I'm able to reproduce it now. I'll release a fix soon.

@bhch bhch added the bug Something isn't working label Nov 13, 2023
@bhch bhch changed the title Const field does not have default value When initial form data is empty, the widget doesn't create the expected data structure Nov 13, 2023
@bhch
Copy link
Owner

bhch commented Nov 13, 2023

Fixed in v2.20.2. Please upgrade and test it out.

Thank you for reporting this issue.

@bhch bhch closed this as completed Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants