Skip to content
Open backoffice ↗

Native Umbraco integration · UMBRACO

Block Grid & Block List

Wrap the picker in a reusable Umbraco element type.

Create a reusable form block

  1. Create an Element Type such as “Form block”.
  2. Add a property using MegaForm Form Picker, with alias megaFormPicker.
  3. Add that Element Type to your Block Grid or Block List data type.
  4. Create the corresponding block partial in your site's normal block view folder.
  5. Render the selected form from the block's content value.

Inside the block partial, the important distinction is that the picker value belongs to the element, while the page context belongs to the page containing the block:

@* Inside a block partial where Model.Content is the element. *@
@{
    var formId = Model.Content.Value<int>("megaFormPicker");
}
@if (formId > 0)
{
    <megaform form-id="@formId"></megaform>
}

The exact partial model and view location follow your site's Block Grid/Block List implementation. Register @addTagHelper *, MegaForm.Umbraco in its applicable _ViewImports.cshtml.

Supply page context when needed

If a prevalue source uses the current page as its root, pass the containing content page's ID as content-id. Pass that ID from the page to the block view explicitly. Do not substitute the element's key or treat the element as a content page.

Allow for container width

Test the block in each allowed column span. Standard fields should stack without horizontal scrolling. Custom form backgrounds must stay within the block. See Theme integration and prevalue sources.