Wasn't it better that you took the template for FormContainerBlock, copied it to Views/Shared/ElementBlocks/FormContainerBlock.ascx and added your code?
Marija, Thanks for the reply. A requirement for our build is to be able to use the regular FormContainerBlock for some forms and our custom FormWithMenuContainerBlock for other forms. Also, using this method should still allow updates to the EPiserver.Forms module without having to modify or update the FormContainerBlock.ascx in the future.
Did you solve that problem? We have the same issue.
Unfortunately, I was not able to resolve this. We ended up doing custom MVC forms for this feature. For a different feature, I ended up following Marija's advice. I needed to add an image field to the forms. In order to do this I customized the original FormContainerBlock.ascx. It worked as expected without any viewbag issues. You may want to give it a try using this method, note it will affect all the EpiForms in your implementation.
Reason is the controller FormContainerBlockController.Index() is not get called to populate those values. Means Episerver directly using the template without calling proper controller! Depend on your template coordinator you can find proper place to put your tempalte.
I've created a custom FormContainerWithNavigationBlock that serves as a wrapper for FormContainerBlock. It works as expected in page editor. However, when I preview it or view a published version I'm getting:
"Cannot convert null to 'bool' because it is a non-nullable value type"
Through debugging, I've determined that the ViewBag is coming back empty when I call the original FormContainerBlock View, specifically line 37, but even if I add a null check there, other parameters of the viewbag are null.
Does anyone know he cause of this?