I have a doubt regarding setting up a value provider for prefilling Sitecore forms
, I can see there are examples for simple text input fields
, and it's working, but when I try to set up a value provider for a dropdown list
field it's not working.
I tried below but had no luck, can someone help me to figure out what am doing wrong here?
public class CountryListValueProvider : IFieldValueProvider
{
public FieldValueProviderContext ValueProviderContext { get; set; }
public object GetValue(string parameters)
{
var countries = GetCountries();
var countrList = new ListFieldItemCollection();
foreach (var country in countries.data)
{
countrList.Add(new ListFieldItem
{
Text = country.code,
Value = country.value
});
}
switch (parameters)
{
case "countrList":
return countrList;
default:
return string.Empty;
}
}
}
Or do I need to try something else, like using IListDataSourceProvider
?