November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
To be clear, I have this hierarchy:
ContentArea > [FormBlock] > [FormContainerBlock] > { FormElements }
The render just shows as a label:
Castle.Proxies.FormContainerBlockProxy
Model:
public class FormBlock : BlockBase
{
[Display(
Name = "The Form container",
Description = "Any form fields will be placed within this block.",
Order = 10)]
public virtual FormContainerBlock Form { get; set; }
}
View: (I have tried using @Html.PropertyFor(m => m.Form) but that throws an error stating the FormContainer cannot be used as a Property.)
@model FormBlockViewModel
<div class="body-copy">
<div class="content-container">
<div class="body-copy__wrapper">
<div class="content-container__inner">
@Model.Form
</div>
</div>
</div>
</div>
Does your FormBlock contain anything more than the FormContainerBlock?
Have you considered creating your own block that inherits from FormContainerBlock to add extra information?
Actually we think it will suffice to modify the form config and set a custom view location, to allow customisation, but if that proves unsatisfactory we could subclass the native Block, yes.
Thanks
Ah I think I see what you're looking for.
Also consider that you can replace the default view with something that wraps the original view?
Just look at this file and add it to /Views/Shared/ElementBlocks
And also looking at your code where you write @Model.Form will be the same as doing Model.Form.ToString() and the default behavior when making ToString() on a class is to output its namespace.
I am using the latest EpiServer.Forms nuget package and am trying to place a Form within a ContentArea Block, design time works as expected but when I try to Preview or Publish the page the FormContainerBlock fails to render correctly and instead just displays a text label :
Castle.FormContainerBlockProxy
(^^ I am not on my dev machine right now, the exact text might be slightly different)
Is this hierarchy supported or can a Form only be used directly on a Page?
Any advice much appreciated.