question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Select list default value of 0 does not display in form or preview

See original GitHub issue

Using https://formio.github.io/formio.js/app/builder I was able to re-create an issue we are having in our application.

In a select list if you set the default value to an option whose value is 0, the label does not display in the select list when previewed or rendered. Choosing another default value, in my case the option with with the value 1, works as expected.

Sample form ( I’m assuming the pdf display settings are added by the demo page):

{
    "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,
            "data": {
                "values": [
                    {
                        "label": "Zero",
                        "value": "0"
                    },
                    {
                        "label": "One",
                        "value": "1"
                    }
                ]
            },
            "selectThreshold": 0.3,
            "key": "select",
            "type": "select",
            "indexeddb": {
                "filter": {}
            },
            "input": true,
            "defaultValue": 0
        },
        {
            "type": "button",
            "label": "Submit",
            "key": "submit",
            "disableOnInvalid": true,
            "input": true,
            "tableView": false
        }
    ]
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jalamacommented, Jun 4, 2021

For us it’s still an issue, in fact testing upgrade from 4.13.0 -> 4.13.2 it’s worse as it seems to be changing the values in a select list from numbers we set programmatically to camelCase string versions of the label. This is happening in a form we have not changed in month and appears to be happening when the form is rendered, which is really disturbing.

1reaction
jalamacommented, Jan 29, 2021

@wag110894 I think you are misunderstanding what I am trying to accomplish here. I don’t want the value to be displayed, I want the label to be displayed. Which I understand I can make happen by changing the storage type for the component to string.

Though I think it’s a bug that by default the select component stores the default value as an integer while the data source values are store as stings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

default select option as blank - html - Stack Overflow
This solution partially works with Chrome 35: the dropdown does not show any selection when the list of option is invisible, but shows...
Read more >
SSRS 2008 parameter default value not displaying in ... - MSDN
When we preview the report, it will display all records automatically with all values selected in the parameter.
Read more >
Form Select | Components - BootstrapVue
In non multiple mode, <b-form-select> returns the a single value of the currently selected option. Please select some item, This is First option,...
Read more >
How to set the default value for an HTML <select> element
The default value of the select element can be set by using the 'selected' attribute on the required option. This is a boolean...
Read more >
Power Apps Dropdown Control - How to use - SPGuides
Save, Publish and Close the app. When you wil reopen the app and form again, you can see the dropdown default value will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found