Skip to content

Custom Default value is not working as expected in Select Component #6262

@SumeetKumarTiwariJava

Description

@SumeetKumarTiwariJava

Describe the bug
If I add the below JavaScript in the Custom Default Value, the Select component value appears multiple times.

console.log(">>> selectJson custom_default_value");

    return [{label:"cedric",value:"01"},

            {label:"Irene",value:"02"} ,

            {label:"Gisa",value:"03"}

          ];

Version/Branch
sandbox default version /4.14.6

To Reproduce
Steps to reproduce the behavior:

  1. Create form.

  2. Add Select component.

  3. Edit the form and navigate to the Data tab

  4. Select the Multiple values

  5. Edit the custom Default value

  6. Add this in Javascript
    console.log(">>> selectJson custom_default_value");

     return [{label:"cedric",value:"01"},
    
             {label:"Irene",value:"02"} ,
    
             {label:"Gisa",value:"03"}
    
           ];
    

Expected behavior
Only unique values should be displayed — currently, I can see duplicate entries.

Screenshots
If applicable, add screenshots to help explain your problem.

Image

Additional context
Hosting Type :
https://formio.github.io/formio.js/app/sandbox.html
formio js version : default version /4.14.6

Form JSON :

{
"display": "form",
"components": [
{
"label": "Select",
"widget": "choicesjs",
"tableView": true,
"multiple": true,
"customDefaultValue": "console.log(">>> selectJson custom_default_value");\n \n return [{label:"cedric",value:"01"},\n \n {label:"Irene",value:"02"} ,\n \n {label:"Gisa",value:"03"}\n \n ];",
"validateWhenHidden": false,
"key": "select",
"type": "select",
"input": true
},
{
"type": "button",
"label": "Submit",
"key": "submit",
"disableOnInvalid": true,
"input": true,
"tableView": false
}
]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions