Custom form rendering using the built in FormContainerBlock


I'm trying to perform some custom rendering of a form using Epi Forms 5.4.0. I do not want to copy the contents of the FormContainerBlock.cshtml located in the but rather just render the block using what's already there.

This is the controller:

[TemplateDescriptor(AvailableWithoutTag = true,
    ModelType = typeof(LeadsFormBlock))]
public class LeadsFormBlockController : FormContainerBlockController {
    protected override IViewComponentResult InvokeComponent(FormContainerBlock currentBlock) {
        if(currentBlock is LeadsFormBlock leadsFormBlock) {
            var viewModel = new LeadsBlockViewModel { CurrentBlock = currentBlock, OtherProperty = leadsFormBlock.OtherProperty };

            return View("Index", viewModel);

        return base.InvokeComponent(currentBlock);

And the view:
@model LeadsBlockViewModel

<div class="custom-class">
    <h3>This is the wrapping form!</h3>
    <strong>@Model.OtherProperty</strong> @* Works *@ 
    @Html.PropertyFor(x => x.CurrentBlock) @*Does not work/Renders nothing*@
    @await Html.PartialAsync("FormContainerBlock", Model.CurrentBlock) @*Crashes because cannot find the view*@ 

Edited, Mar 07, 2023 11:16

Hello Mårten,

The root path to find the forms views is under /FormsViews/ and then it's pretty much as per the structure in the file.  So in the case of the FormContainerBlock you can use the following:

@model MyBuild.Features.Blocks.CustomForm.CustomFormBlock

    <h2>Hello World</h2>
    @await Html.PartialAsync("~/FormsViews/Views/ElementBlocks/Components/FormContainerBlock/FormContainerBlock.cshtml", Model);
Mar 10, 2023 15:19

Thank you Mark! :)

Mar 20, 2023 14:04
* 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.