Try our conversational search powered by Generative AI!

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

Vote:
 

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 0.21.1.9000, created a form, dragged into a content area and outputted it using Html.PropertyFor(). What am I doing wrong? Thanks for the help!

#143150
Jan 13, 2016 15:44
Vote:
 

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?

#143161
Jan 14, 2016 4:13
Vote:
 

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).
#143165
Jan 14, 2016 8:32
Vote:
 

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.

#143166
Jan 14, 2016 9:21
Vote:
 

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?

#143170
Jan 14, 2016 9:39
Vote:
 

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.

#143171
Jan 14, 2016 10:06
Vote:
 

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?

#143172
Jan 14, 2016 10:17
Vote:
 

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

#143174
Jan 14, 2016 10:30
Vote:
 

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

#143176
Jan 14, 2016 10:39
Vote:
 

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

http://world.episerver.com/forum/developer-forum/-Episerver-75-CMS/Thread-Container/2016/8/quotreferenceerror-epi-is-not-definedquot-atheader-not-working-episerver-forms/

#152194
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.