November Happy Hour will be moved to Thursday December 5th.

Error in customization form container??

Vote:
 

Hi Guys,

   i want to create my own form conatainer, I extract the Forms.UI folder and took FormContainerInitScript.ascx as reference code,here is my code

  CustomFormContainerBlock.cs: 

  namespace EpiserverSite5.Models.CustomElements

   {

     [ContentType(DisplayName = "Custom Form ContainerBlock", GUID = "57d9f7b1-5bc4-4d96-9921-5f07bf176c49", Description = "")]

     public class CustomFormContainerBlock : FormContainerBlock

     {

       

      }

   }

  CustomFormContainerBlockController.cs:

   public class CustomFormContainerBlockController : BlockController

   {

    public override ActionResult Index(CustomFormContainerBlock currentBlock)

    {

        return PartialView(currentBlock);

     }

    }

    Index.cshtml:

    @model EpiserverSite5.Models.CustomElements.CustomFormContainerBlock
    @using System.Web.Mvc
    @using EPiServer.Forms.Helpers.Internal
    @using EPiServer.Forms.Implementation.Elements
    @using EPiServer.Forms.EditView.Internal
    @using EPiServer.ServiceLocation

    

@{
    Layout = null;
   }


 
 
  Index
 


@{
var _formParagraphTextService = ServiceLocator.Current.GetInstance();
var _formValidationService = ServiceLocator.Current.GetInstance();
var _formDataSubmissionService = ServiceLocator.Current.GetInstance();
var _formConfig = ServiceLocator.Current.GetInstance();
}

Using aboce code i able to drag and drop in container but am unable to display it in admin mode and UI mode,if anyone have any idea regrad this matter can any one help me out of this.

Thanks,

Kartheek

#187435
Jan 23, 2018 7:33
Vote:
 

Hi, Kartheek,

To begin with, it's a partial view, so you shouldn't have the entire page with Layout and <html>...

Probably PartialView(currentBlock) is not looking in the same place you put your Index.cshtml, you can try that out by specifying the path to the file.

BR,
Marija

#187458
Jan 23, 2018 14:44
Vote:
 

See also https://support.episerver.com/hc/en-us/articles/115002855631-Custom-Forms-Element-view-with-Razor-code

#187459
Jan 23, 2018 14: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.