Skip to content

Create a select field (drop-down) with a valid null-value when selection is empty/cleared #4459

Answered by eLikeInEden
eLikeInEden asked this question in Q&A
Discussion options

You must be logged in to vote

After some further digging in the other rjsf forums for Issues I found this post #4422
and finally adjusted the properties to this:

"select_static": {
    "title": "SelectStatic",
    "type": [
        "string",
        "null"
    ],
    "oneOf": [
        {
            "const": "value1",
            "title": "First Choice"
        },
        {
            "const": "value2",
            "title": "Second Choice"
        },
        {
            "const": null,
            "title": " - " //see below
        }
    ],
    "default": null
},

This will produce a selection drop-down with three entries.
If I do nothing further, it will show " - " to the user, which will produce null.

To make it a…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@eLikeInEden
Comment options

Answer selected by eLikeInEden
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant