Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Forms 5.7.2 not finding custom Forms elements

Vote:
 

I have some custom Forms elements that resides in a shared project. This shared project holds all the episerver code and nuget packages for EPi. The view is with the built in views as indicated in Forms.config (formElementViewsFolder="~/Views/Shared/ElementBlocks"). I have a separet project for EPi Admin and another project for the front end. This custom element doesn't show anywhere with EPi Admin or the frontend project. I would expect it show show under "BasicElements" so I can add it to the Forms block.

I have validated that on project start, it is hitting the StateElementBlock with a breakpoint on weAreHere.

    /// <summary>
    /// State Element Block
    /// </summary>
    [ContentType(GUID = "MY GUID REMOVED", 
                 DisplayName = "State Selection",
                 Description = "List of States",
                 GroupName = ConstantsFormsUI.FormElementGroup, 
                 Order = 999)]
    [EPiServerFormElementImage("selectionelementblock.png")]
    public class StateElementBlock : SelectionElementBlock
    {
          public StateElementBlock()
          {
                  bool weAreHere = true;
          }

        /// <summary>
        /// Local list of OptionItems for State
        /// </summary>
        private List<OptionItem> states;

        /// <summary>
        /// Get Items
        /// </summary>
        /// <returns></returns>
        public override IEnumerable<OptionItem> GetItems()
        {
            //string Caption
            //string value
            //bool? checked

            if (this.states != null && this.states.Any())
                return this.states;

            var dataContext = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<Mosaic.Models.Helpers.IDataContext>();

            List<State> stateList = [.. dataContext.QueryableSet<State>().OrderBy(x => x.Abbrev)];

            if (stateList != null && stateList.Any())
            {
                this.states =
                [
                    new OptionItem
                    {
                        Caption = "Please select a State",
                        Checked = true,
                        Value = "0"
                    }
                ];

                foreach (State state in stateList)
                {
                    this.states.Add(new OptionItem
                    {
                        Caption = string.Format("{0} - {1}", state.Abbrev, state.FullName),
                        Checked = false,
                        Value = state.Abbrev
                    });
                }
            }

            return this.states;
        }
    }
}
#316763
Edited, Feb 06, 2024 20:06
* 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.