I’m trying to get the values from TextOption but it just returns null.
I’ve set it up in AcceleratorWebsiteFieldDefinitionSetup and added some options to it.
When i’m trying to get the values in my ViewModelBuild with website.Fields.GetValue<IList<string>>(PageFieldNameConstants.MyTextOptionField, CultureInfo.CurrentUICulture); it just returns null.
(website is _requestModelAccessor.RequestModel.WebsiteModel)
Is the field multi-culture? Otherwise, you should omit CultureInfo.CurrentUICulture.
You can also use the WebsiteModel directly, like websiteModel.GetValue<IList<string>>(PageFieldNameConstants.MyTextOptionField) and it will check with and without culture automatically.
Do you want to get all the possible values for the field?
And not the selected values for the field on the current website?
If so, then you should get the definition of the field instead. Something like:
var field = _fieldDefinitionService.Get<WebsiteArea>(PageFieldNameConstants.MyTextOptionField);
var options = field.Option as TextOption;
var values = options.Items.Select(option => option.Value);