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

[BUG] When adding a Select Boxes with a few values, the defaultValue property always has an invalid value. #5897

Open
pboucher1960 opened this issue Nov 5, 2024 · 4 comments
Assignees

Comments

@pboucher1960
Copy link

pboucher1960 commented Nov 5, 2024

Describe the bug
When adding a Select Boxes to a form with a few values, the defaultValue property field always has an invalid value until we select and unselect one of the existing values as a default value.

Version/Branch
The latest version of the Form.io playground

To Reproduce
Steps to reproduce the behavior:

  1. In the Form.io playground, create a form.
  2. Add a "Select Boxes" component.
  3. In the "Data" tab, set the "Data Source Type" property to "Values".
  4. Add a few values (Option1, Option2 and Option3 for this example).
  5. Save the component and look at the generated JSON schema.
{
    "display": "form",
    "components": [
        {
            "label": "Select Boxes",
            "optionsLabelPosition": "right",
            "tableView": false,
            "values": [
                {
                    "label": "Option1",
                    "value": "option1",
                    "shortcut": ""
                },
                {
                    "label": "Option2",
                    "value": "option2",
                    "shortcut": ""
                },
                {
                    "label": "Option3",
                    "value": "option3",
                    "shortcut": ""
                }
            ],
            "validateWhenHidden": false,
            "key": "selectBoxes",
            "type": "selectboxes",
            "input": true,
            "inputType": "checkbox",
            "defaultValue": {
                "o": false
            }
        }
    ]
}
  1. Edit the component.
  2. In the "Data" tab, check and uncheck one of the values under the "Default Value" property.
  3. Save the component and look at the generated JSON schema.
{
    "display": "form",
    "components": [
        {
            "label": "Select Boxes",
            "optionsLabelPosition": "right",
            "tableView": false,
            "defaultValue": {
                "option1": false,
                "option2": false,
                "option3": false
            },
            "values": [
                {
                    "label": "Option1",
                    "value": "option1",
                    "shortcut": ""
                },
                {
                    "label": "Option2",
                    "value": "option2",
                    "shortcut": ""
                },
                {
                    "label": "Option3",
                    "value": "option3",
                    "shortcut": ""
                }
            ],
            "validateWhenHidden": false,
            "key": "selectBoxes",
            "type": "selectboxes",
            "input": true,
            "inputType": "checkbox"
        }
    ]
}

Expected behavior
I would expect the have the same JSON Schema as in the result of step 9.

@lane-formio
Copy link
Contributor

I'm trying to understand notion of "the defaultValue property always has an invalid value".

When you look at the submission json you can see they are being set to "false" as expected.

@pboucher1960
Copy link
Author

@lane-formio When you look at the json under step 5, the default value is "o": false. The "o" option is not a valid value since, in my example, the only possible values are "option1", "option2" and "option3".

@lane-formio
Copy link
Contributor

Ah, I see, I missed that. I'll get this reviewed more in-depth.

@daneformio
Copy link
Contributor

We created a ticket for this which is being worked on for new versions of the renderer.
Ticket for internal tracking: FIO-9327

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants