Is there a way to choose a default value for a selection field of a form?


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?

Aug 01, 2019 20:40

Are you using the Epi Forms add-on? If so, which version?

Aug 01, 2019 23:04

Yes, latest version 4.25

Aug 01, 2019 23:33

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.

Edited, Aug 02, 2019 16:52
Edited, Aug 02, 2019 16:19

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.

Aug 02, 2019 16:58

Hi Jason,

Have you checked the link that I provided? It is the same link that Bob mentioned in his comment.

Aug 02, 2019 17:01

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.

Aug 02, 2019 17:12

Anyone have any suggestion how to do this? Surely I can't be the only one who has had this requirement for dynamic sources.

Aug 16, 2019 16:35

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;

Feed Provider
public class FeedProvider : IFeedProvider{
public IEnumerable<IFeed> GetFeeds(){
return ServiceLocator.Current.GetAllInstances<IFeed>();}}
Custom form element with overriden GetDefaultValue.
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.

Edited, Aug 19, 2019 20:59
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.