formio / formio.js

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

[BUG] Radio component with duplicate option values #2786

Closed sharique5 closed 4 years ago

sharique5 commented 4 years ago

Environment

Please provide as many details as you can:

Steps to Reproduce

  1. Create a formio form with Radio Component
  2. Add options in radio component with a duplicate key
  3. Click on the option label with duplicate key GIF with steps to reproduce: https://gifyu.com/image/n3ug

Expected behavior

Clicked label option should get selected

Observed behavior

First option with the key is getting selected

Example

https://codepen.io/sharique_5/pen/gOajgGg

Form Config:

{
    "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": "Radio",
            "optionsLabelPosition": "right",
            "inline": false,
            "tableView": false,
            "values": [
                {
                    "label": "First",
                    "value": "first",
                    "shortcut": ""
                },
                {
                    "label": "Second",
                    "value": "second",
                    "shortcut": ""
                },
                {
                    "label": "FirstDuplicate",
                    "value": "first",
                    "shortcut": ""
                }
            ],
            "calculateServer": false,
            "key": "radio1",
            "type": "radio",
            "input": true
        },
        {
            "type": "button",
            "label": "Submit",
            "key": "submit",
            "disableOnInvalid": true,
            "input": true,
            "tableView": false
        }
    ]
}
wag110894 commented 4 years ago

@sharique5 This is occurring because of the values of First and FirstDuplicate must be unique.

I hope that this helps.

sharique5 commented 4 years ago

Thank you @wag110894