formio / formio.js

JavaScript powered Forms with JSON Form Builder
https://formio.github.io/formio.js
MIT License
1.89k stars 1.07k forks source link

Multiple select box displays undefined values #4691

Closed krixerx closed 9 months ago

krixerx commented 2 years ago

I defined a select box with:

Schema:

{
    "display": "form",
    "settings": {
        "pdf": {
            "id": "1ec0f8ee-6685-5d98-a847-26f67b67d6f0",
            "src": "https://files.form.io/pdf/5692b91fd1028f01000407e3/file/1ec0f8ee-6685-5d98-a847-26f67b67d6f0"
        }
    },
    "components": [
        {
            "label": "Select",
            "widget": "choicesjs",
            "tableView": true,
            "multiple": true,
            "dataSrc": "url",
            "data": {
                "url": "https://bpa.dev.lesotho.eregistrations.org/restheart/catalog/2p22p73_858368_858368.en/2c9280947d2e20a8017d2e52b3f2001b?pagesize=300&sort_by=customOrder",
                "headers": [
                    {
                        "key": "",
                        "value": ""
                    }
                ]
            },
            "dataType": "object",
            "idPath": "key",
            "template": "<span>{{ item.value }}</span>",
            "refreshOn": "data",
            "searchEnabled": false,
            "clearOnHide": false,
            "customDefaultValue": "value=[{\"key\": \"1 poland\"},{\"key\": \"5 canada\"}]",
            "key": "select",
            "type": "select",
            "lazyLoad": false,
            "selectValues": "values",
            "disableLimit": false,
            "input": true,
            "defaultValue": [
                {}
            ]
        }
    ]
}
CHASESY commented 2 years ago

Is it just the default values that are showing as undefined or all the options in the select that show as undefined? I went to re-create this in our https://formio.github.io/formio.js/app/builder and I'm seeing undefined for the default values, but not for all the options in the select.

I was, however, able to get this to work with no undefined values. Here's my components property:


        {
            "label": "Select",
            "widget": "choicesjs",
            "tableView": true,
            "multiple": true,
            "dataSrc": "url",
            "data": {
                "url": "https://bpa.dev.lesotho.eregistrations.org/restheart/catalog/2p22p73_858368_858368.en/2c9280947d2e20a8017d2e52b3f2001b?pagesize=300&sort_by=customOrder",
                "headers": [
                    {
                        "key": "",
                        "value": ""
                    }
                ]
            },
            "dataType": "object",
            "idPath": "key",
            "template": "<span>{{ item.value }}</span>",
            "key": "select",
            "type": "select",
            "input": true,
            "lazyLoad": false,
            "defaultValue": [
                {
                    "key": "1 poland",
                    "value": "Poland",
                    "customOrder": 0
                },
                {
                    "key": "5 canada",
                    "value": "Canada",
                    "customOrder": 4
                }
            ],
            "selectValues": "values",
            "disableLimit": false
        },
        {
            "type": "button",
            "label": "Submit",
            "key": "submit",
            "disableOnInvalid": true,
            "input": true,
            "tableView": false
        }
    ]```
daneformio commented 9 months ago

Closing this thread as it is outdated. Please re-open if it is still relevant. Thank you for your contribution!