SaaS CMS has officially launched! Learn more now.

"Uncaught ReferenceError: epi is not defined" when displaying a form (the new episerver forms)


As the title says I am getting an client side error when displaying an episerver form in the view. The form is only a textbox and a submit button. This is where the debugger points at ()

GetFormInitScript?formGuid=a0639452-1cfc-4007-9f7b-7cd0ba73d527&formLanguage=en:6 Uncaught ReferenceError: epi is not defined
(function initializeOnRenderingFormDescriptor() {
    // each workingFormInfo is store inside epi.EPiServer.Forms, lookup by its FormGuid
    var workingFormInfo = epi.EPiServer.Forms["a0639452-1cfc-4007-9f7b-7cd0ba73d527"] = { // code ommited }

All I have done is basically downloaded the nuget package, version, created a form, dragged into a content area and outputted it using Html.PropertyFor(). What am I doing wrong? Thanks for the help!

Jan 13, 2016 15:44

Now directly using FormContainerBlock as a Content type's property is not supported.

Forms has this kind of error when is rendered at Footer (such as Alloy's Footer.cshtml).

Could you please tell how you use Forms?

Jan 14, 2016 4:13

Thanks for the answer. I use it very straigforward. I have a View that uses 

@model myPageModel

@Html.PropertyFor(x => x.MyContentArea)

This view uses the layout.cshtml. The model is first passed via a controlller (that only passes the model to the view directly). 

When I read the documentation is says 

  • When all elements are published and the form is ready, publish the form. It is ready to use on a page (like any other block).
Jan 14, 2016 8:32

Now the Forms' resources is registered through a controller, not an implementation of IClientResourceRegister and then somehow the required resources is not loaded.

I do not know how your layout.cshtm looks like, but a similar error happens if trying render a Forms in Footer.cshtml view of Alloy template in straightforward like you do:

1. Adding a property (FooterFormsArea) of ContentArea to SitePageData

2. In Footer.cshtml adding

@Html.PropertyFor(m => m.CurrentPage.FooterFormsArea)

Then you can try render the Forms somewhere in the body to see any difference.

Jan 14, 2016 9:21

Thanks for the tips.

I can say "Layout = null" and there is still this problem. I don't render it in a partial view, rather in the main view.

Does that help in any way?

Jan 14, 2016 9:39

Does  "Layout = null" mean the Forms has no element in it? 

You should check the Forms' resources has been loaded or not, there are two embedded script files (jQuery v1.7.2, EPiServerForms.js) handled by WebResource.axd.

It is the case if no finding them.

Jan 14, 2016 10:06

Layout = null means that we don't render the layout file.

Ok, the only file loaded is actually a file named GetFormInitScript. Nothing else. It's in the file that the epi error occurs.

What do I need to do to make the correct files load?

Jan 14, 2016 10:17

Make sure the view has @Html.RequiredClientResources("Header") and @Html.RequiredClientResources("Footer"), see the Alloy's _Root.cshtml.

Jan 14, 2016 10:30

Perfect, thanks! It was me that hadn't added thoses resources!

Jan 14, 2016 10:39

Im having simular problems with AtHeader not being populated, please help

Aug 19, 2016 9:14
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.