Try our conversational search powered by Generative AI!

Dynamically add fields to a form on render

Vote:
 

Hi,

My client wants to use data from the page to dynamically add fields to a form (form is to register for a seminar, the seminar has agenda blocks which are rendered on screen), the forms will be radio buttons/check boxes to select which agenda items they wish to attend. Has anyone done anything similar to this? Essentially adding fields on render.

Thanks

Andy

#290622
Oct 26, 2022 16:24
Vote:
 

You can implement the IFeedProvider and IFeed to dynamically load in custom values into the Selection Element Blocks 

e.g. 

    [ServiceConfiguration(ServiceType = typeof(IFeed))]
    public class AnimalAgeFeed : IFeed, IUIEntityInEditView
    {
        public string ID => "A984BE22-C761-4944-AF24-ED8C040BD519";

        public string Description { get; set; } = "Animal age feed";

        public string ExtraConfiguration { get; }

        public string EditViewFriendlyTitle => Description;

        public bool AvailableInEditView => true;

// Hard coded but you can any business logic here i.e. to get values from parent page
        public IEnumerable<IFeedItem> LoadItems()
        {
            yield return new FeedItem { Key = "puppy", Value = "Puppy" };
            yield return new FeedItem { Key = "kitten", Value = "Kitten" };
            yield return new FeedItem { Key = "adult", Value = "Adult" };
            yield return new FeedItem { Key = "senior", Value = "Senior" };
            yield return new FeedItem { Key = "any", Value = "Any" };
        }
    }
    public class CustomFeedProvider : IFeedProvider
    {
        public IEnumerable<IFeed> GetFeeds()
        {
            return new IFeed[] {
                new AnimalAgeFeed(),
            };
        }
    }

#290663
Oct 26, 2022 23:00
* 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.