[BUG] When adding a Select Boxes with a few values, the defaultValue property always has an invalid value.
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:
- In the Form.io playground, create a form.
- Add a "Select Boxes" component.
- In the "Data" tab, set the "Data Source Type" property to "Values".
- Add a few values (Option1, Option2 and Option3 for this example).
- 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
}
}
]
}
- Edit the component.
- In the "Data" tab, check and uncheck one of the values under the "Default Value" property.
- 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.
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.
@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".
Ah, I see, I missed that. I'll get this reviewed more in-depth.
We created a ticket for this which is being worked on for new versions of the renderer. Ticket for internal tracking: FIO-9327