Custom Forms Containers in CMS 12

Vote:
 

We are upgrading from CMS 11 and CMS 12. One of the many problems that we have encountered is related to forms. We have a custom FormContainerBlock (that is heavily used on our sites). It was implemented a long time ago by developers who no longer are on the team and we who are have limited experience with this part of the product. I've tried to find documentation about how to work with custom form containers in CMS 12, but I'm either really bad at googling this or the available documentation is very sparse. Basically, the only useful page I've found so far is How to create custom FormContainerBlock in CMS 12 – Support Help Center (optimizely.com), which really doesn't contain much information.

  1. Are there any better/additional sources for information about this subject?

  2. Is it true what is said on the aforementioned page, that to create a custom form container you make a copy of the file FormContainerBlock.cshtml in folder \modules_protected\EPiServer.Forms\EPiServer.Forms.zip\Views\ElementBlocks\Components\FormContainerBlock? This might be what my predecessor once upon a time did, but it just doesn't seem very future proof as our current version is no longer compatible and quite different from the .cshtml in the new Zip file. This makes me wonder if there could be a better alternative?

Any input on this would be greatly appreciated

#310712
Oct 12, 2023 15:04
Vote:
 

We had similar thing in our upgrade. This is what we have done.

Since Forms has changed a lot in the latest version. Create a folder ElementsBlocks and then create Components folder wherever you are rendering your partials. My structure is as shown below.

Views --> Shared --> ElementsBlocks --> Components --> YourFormContainerName --> FormContainerBlock.cshtml.

This cshtml you can have your rendering code (essentially old forms html code). Also please ensure to FormContainerInitScript.cshtml from the modules/forms folder in the ElementsBlocks folder as it is required for form to render. Unfortunately I can put a snapshot but try this out and should work

#310784
Edited, Oct 13, 2023 18:11
Vote:
 

Thanks DD! I think we're doing it in a way equivalent to what you suggest, and it (knock on wood) seems to work. I'm not really happy with that solution though, but maybe I just have to accept it and hope it will be better in future versions 😊.

#311430
Oct 25, 2023 13:09
Dileep D - Oct 26, 2023 13:39
Yes it did seem like a hack rather than solution and we did struggled with this. Glad that its working.
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.