Try our conversational search powered by Generative AI!

How would Iinject Client Resources in a common Layout for only those pages that actaully contain an epi Form?

Vote:
 

How would I to inject Client Resources in a common Layout for only those pages that actaully contain an epi Form? If I add these to the header and footer, everything works. My concern is that I only want to inject them for pages that contain a form block.

@Html.RequiredClientResources(RenderingTags.Header)

@Html.RequiredClientResources(RenderingTags.Footer)

#199856
Dec 13, 2018 22:11
Vote:
 

You can define your element which require client resource, then just declare the resources path. Forms will load your resources automatically. Please sample here: https://github.com/episerver/EPiServer.Forms.Samples/blob/master/Implementation/Elements/AddressesElementBlock.cs

(The method GetExtraResources)

#199874
Dec 17, 2018 9:06
Vote:
 

How would this work for the built in form elements that require that the default javascript get loaded? I'm not trying to load additional client resourcves, just the ones required for all epi form elements of type FormContainerBlock.

Would I need to override each built in form element. I'm current trying to loop over all the current page blocks and determine if any are of type FormContainerBlock. My issue is that I can't figure out how to get blocks for XHtmlString and ContentAreas before the page saving event. Right now I'm using the page Saved event and getting page SoftLinks to deterine if any are of type FormContainerBlock.

#200158
Jan 03, 2019 21:09
* 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.