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

Issue : Unable to set the Default Values in the Select Component with multiselect enabled #5172

Closed rpkraghu7 closed 8 months ago

rpkraghu7 commented 1 year ago

Hi, I have a scenario to pre-populate the multi select dropdown with all the options I provide in the "values" key of the Select dropdown.

Issues absorbed:

  1. When I tried to pass the same options array in the "defaultValue" key, which I passed in the "values" key for the dropdown options. It was not working. Sample Options format given for the "values" key data:{ values:[ { label:"option1", value:"optionValue1" } ] }.
  2. I'm able to achieve the above scenario, if I pass the "defaultValue" key a plain array of texts (Eg :an array of labels from my options). But when I try to remove any options, the removed option is getting added to the existing options list again which creates duplicate entries. (in this case, dropdown is also populated with the options array given in the "values" key along with default values, which is not expected). Ideally it should check the default value with the options list and eliminate the pre-populated options and prevent them from showing in the dropdown. But that's not happening
  3. So ideally, I should not see any options showing in the dropdown, if I had pre-populated all the options in the field (as per the behaviour of the Select Component in formio). I'm trying to achieve the same here.

Any help would be appreciated. Thanks in advance.

travist commented 1 year ago

Can you please provide either a sandbox of this issue (https://formio.github.io/formio.js/app/sandbox.html) or a jsfiddle so that we can see what you are running into? It is hard to visualize the issue from your description.

lane-formio commented 8 months ago

@rpkraghu7 Going to go ahead and close this issue as we haven't heard back from you. If you have more information so we might assist you better please let us know!