Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.

 

Episerver Forms on non-MVC Razor project

Vote:
 

I know that docs here (https://docs.developers.optimizely.com/content-cloud/v1.2.0-forms/docs) says,
that "Optimizely Forms is only supported by MVC-based websites and HTML5-compliant browsers.",

but still is there any way to make Forms work on non-MVC razor projects on FE side?

#288556
Edited, Oct 03, 2022 12:24
Vote:
 

Could you possibly use the Conetent Delivery API or Content Definitions API (https://world.optimizely.com/documentation/class-libraries/rest-apis/content-definitions-api/) to retrieve Forms and their Fields and then build the frontend in whatever framework you use. You could also use the Forms Service API to retrieve data. (https://docs.developers.optimizely.com/content-cloud/v1.2.0-forms/docs/using-forms-serviceapi

#288563
Oct 03, 2022 13:11
klappo - Oct 03, 2022 13:20
so, it's not really possible to use existing epi code to render form and inject it into any other page?
Vote:
 

@Klappo is your solution headless or are you trying to use a completely different server side rendering engine to the CMS?

If you're going to want to embed the form with an iFrame along those lines, you could potentially look a single MVC Razor page which is designed to hold a single form container block so that you get all of the forms handling out of the box.  But this does feel a little hacky.

You could follow Minesh's solution to build the form and then submit the response to the following url as form data.  This is based on the EPiServer.Forms.Controllers.DataSubmitController  

https://example.com/EPiServer.Forms/DataSubmit/Submit/

I would add that I've not needed to do any of the above, but it would be interesting to try.

#288568
Oct 03, 2022 17:00
Vote:
 

Have a look at this blog post, it's old but (so are webforms and) it might help...

https://jstemerdink.blog/2016/08/17/forms-and-webforms/

#288571
Oct 03, 2022 19:14
Vote:
 

Thanks everybody for the help!

In the end I was able to implement that. I had to copy Forms cshtml view, override default Forms ViewComponent
and fix null ref exceptions (viewcomponent supposes that it is rendered on some page). 

I had issues wth the order of view component parts rendering, but, again, I fixed that as well.

Then I was able to load the form by its id and submit some data to epi.

#290200
Edited, Oct 18, 2022 7:08
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.