November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Have you read Form element types, which explains how to work with the two types of dropdowns: "Selection" and "Multiple or Single Choice" ? The Choices fields have a Checked by default property.
Hey Bob,
The link seems to be broken that you shared in your last comment.
Hey Praful,
The correct URL is http://webhelp.episerver.com/latest/en/addons/forms/form-element-types.htm
Thanks
Ravindra
Both of those links are broken. The "checked by default" property is only available if you manually enter the choices. If you choose a selection feed there is no way to choose the default value. Was hoping you guys had a workaround.
Hi Jason,
Have you checked the link that I provided? It is the same link that Bob mentioned in his comment.
Yes I did, thanks. It only describes how to use the selection field for manual input choices. There is no mention of how to choose a default when you use a selection feed to fill the choices.
Anyone have any suggestion how to do this? Surely I can't be the only one who has had this requirement for dynamic sources.
After reading Kenny's post I realized the view of a SelectionElementBlock calls GetDefaultValue and GetDefaultSelectedString. You should be able to create a custom form element that inherits SelectionElementBlock and override those two methods to whatever you'd like.
Dummy feed
[ServiceConfiguration(ServiceType = typeof(IFeed))]
public class CustomFeed : IFeed, IUIEntityInEditView {
public IEnumerable<IFeedItem> LoadItems(){
var feedItems = new List<IFeedItem>();
feedItems.Add(new FeedItem { Key = "Custom data 1", Value = "1" });
feedItems.Add(new FeedItem { Key = "Custom data 2", Value = "2" });
feedItems.Add(new FeedItem { Key = "Custom data 3", Value = "3" });
return feedItems;
}
public class FeedProvider : IFeedProvider{
public IEnumerable<IFeed> GetFeeds(){
return ServiceLocator.Current.GetAllInstances<IFeed>();}}
public class DefaultValueSelectionBlock : SelectionElementBlock{
public override string GetDefaultValue(){
return "3";}}
Sending the default value of "3" will set the FeedItem with key "Custom data 3" as default when the dropdown is rendered.
I have a dropdown field on a form that is data driven by a selection feed. Is there a way to choose what the default value of the dropdown will be when it loads?