I have a form that has initial data from my database for updates.
In it I have a field named cities, which is a string such as: "Los Angeles, San Jose"
In the form I created a multiselect field that has a list of cities filtered by state as source data, so the cities names are both value and label.
The default value I'm trying to use is:
{{ form5.initialData.cities.split(", ") }}
this returns an array as ["San Diego", "Los Angeles"], both available in my cities options both as label and value
Yes, multiselect components behave strangely and differently than other components within forms. In general I find the key value , which usually should take from the form data source, will not work (I think this field isn't able to read objects). As you rightly tried, default value is the way to go and it is strange that even when you manually tried hard coding ["Los Angeles"] it didn't work.
This will sound strange, but have you tried refreshing the page? This often helps the form properly evaluate default values
One detail to note is that you cannot override the form data with the default value.
Since your multiselect form data key is cities, it is trying to set the default value to 'San Diego, San Jose', even though you have the correctly formatted value in the default field. You can confirm this by clearing the form data key field under Interaction
The best practice would be to keep the form data key and make sure the data is properly formatted in the form's initial data. Here's one way to do this (where query1 is the database query populating the form):