Forum Academy Marketplace Showcase Pricing Features

Can't set multidropdown values from custom state

Hi

If I set the default value of a multidropdown to a text list custom state, it only works for one value.
If there is more than one value it gets blank.

I wanted to use it to save to localstorage as a csv and then retrieve on page load.
This is to save the multidropdown values even for logged-out users, I don’t want to save to database.

Well, yes, because the default selection is just one value. (A scalar [single] value, not a list [an array] of values.) It represents one of the values from a list of possible values that should be the default selection.

I guess one could do this as csv files are text, but I think you’re confused about how localStorage works.

You might be looking for Option Sets?

It’s really hard to understand what you’re trying to do here because your description of whatever it is you’re trying to do is nearly nonsensical.

1 Like

I got it to work, when the multidropdown changes I write its value to localstorage, that creates a csv separated by ", " (notice the extra space after ,).

Then I set the default value to a custom state with a list of text.

Then when the page loads I read from localstorage and split by ", " with the space, to recreate the list of texts, and set that to the custom state.

When the page loads, the multidropdown will have the same values from the last time it was set.

1 Like