Dynamically set the value of a multiselect dropdown

I have previous selected values from a multiselect dropdown saved.

On loading the app at some point, I want to set the value of the dropdown to the previously multi-selected values e.g:

  if len(field_plots) == 0:
            return ['']
            return field_plots

I keep having an error that length of 1 is expected not length of 2 or 3 that was passed.

How do I set the value of the dropdown to these previously selected options dynamically so that if there were saved options, it will automatically select them and show in the dropdown like this e.g?



When you say “previously selected options”, do you mean literally the last selection before the current one or a specific (hardcoded) list of choices that should be the default?

It might be easier if you share the callback as well, so it makes easier to see the intended behavior and the origin of such error.