I "solved" it by just instansiating a random Form (IForm) which works in this case since I just wanted to render the form in edit mode, I dont think this should be marked as "solved" just yet though.
Form (IForm) model is the pure data model, keep information about the form, relation to its steps, and relation to its elements. It is beneficial to separate the logic of Form in Edit Mode (using Blocks) and that in ViewMode for rendering.
This model can be built independently. With current implementation of Forms, we use Episerver Block as Form, Steps, and Elements. They are all nature blocks. They are organized as steps with "ordering convention" (Elements after a Step belong to that step).
Step1 - E11 - E12 Step2 - E21
To build that "model" from "Blocks implementation", we have
Injected<FormBusinessService> _formBusinessService; _formBusinessService.Service.BuildFormModel(formContainerBlock);
Honestly, this might be considered as a current LIMITATION, we need to call BuildFormModel() before accessing Form property. We see that property FormContainerBlock.Form might return value of _formBusinessService.BuildFormModel(this), but we have not assured that it does not sacrifice too much performance.
So I am implementing Episerver forms for a customer. Their PreviewBlockController looks like so:
Naturally Ill insert something like
The problem is that currentBlock.Form == null which makes the form render with the message
"<%--in case formcontainerblock is used as a property, we cannot build form model so we show a warning message to notify user--%>" (its from this bug, not applicable to my case I think: LINK)%--in>
The forms renders well (Form prop is populated) when its rendered in a contentarea on a page, both on the site and in edit mode (on the page).
Anyone have any idea of whats up here?
(I tried creating a new preview controller inheriting from FormContainerBlockController as seem to work here LINK but with the same error, I also tried using fetching the block from the database with Icontentloader with the same effect)