Umbraco adds scripts and css even if no form is inserted
Hi! I've noticed that Umbraco adds both script and css to the source even if a forms isn't inserted on a page.
It both calls InsertUmbracoForms.cshtml and Form.cshtml. If RenderMode for a form is "script" it will output the script and css to the source. So if I go to a page that doesn't have any form present, it will output all this code for every form.
It seems unnecessary to me to output all this code if no form is inserted. I noticed that on pages that actually has a form present the form is first called with RenderMode = "form" and then RenderMode = "script", followed by all the other forms with RenderMode = "script".
Has anyone else noticed this? Is there a trivial solution for hiding this code if no form is inserted?
Follow the guide for rendering scripts at the bottom of the page, and then in the template where you insert the Render Umbraco Forms Scripts, amend the code to check for presence of forms data:
Current version of forms (4.3.2) causes a client side javascript error (pikaday can't find node) if script is output and there is not a form in response.
Hi Gavin, thanks for the reply! I already have it set up so that it is rendering script at the bottom of the page, my code looks a bit different though.
@if (TempData["UmbracoForms"] != null)
{
foreach (var form in (List<Guid>)TempData["UmbracoForms"])
{
Html.RenderAction("Render", "UmbracoForms", new { formId = form, mode = "script"});
}
}
I noticed know though, for some reason TempData["UmbracoForms"] isn't null. If I debug the site on a page that does not have a form TempData["UmbracoForms"] contains two guids. This even happens if I restart the site.
Umbraco adds scripts and css even if no form is inserted
Hi! I've noticed that Umbraco adds both script and css to the source even if a forms isn't inserted on a page.
It both calls InsertUmbracoForms.cshtml and Form.cshtml. If RenderMode for a form is "script" it will output the script and css to the source. So if I go to a page that doesn't have any form present, it will output all this code for every form.
It seems unnecessary to me to output all this code if no form is inserted. I noticed that on pages that actually has a form present the form is first called with RenderMode = "form" and then RenderMode = "script", followed by all the other forms with RenderMode = "script".
Has anyone else noticed this? Is there a trivial solution for hiding this code if no form is inserted?
Thanks in advance!
Follow the guide for rendering scripts at the bottom of the page, and then in the template where you insert the Render Umbraco Forms Scripts, amend the code to check for presence of forms data:
Current version of forms (4.3.2) causes a client side javascript error (pikaday can't find node) if script is output and there is not a form in response.
Hi Gavin, thanks for the reply! I already have it set up so that it is rendering script at the bottom of the page, my code looks a bit different though.
I noticed know though, for some reason TempData["UmbracoForms"] isn't null. If I debug the site on a page that does not have a form TempData["UmbracoForms"] contains two guids. This even happens if I restart the site.
Created an issue: http://issues.umbraco.org/issue/CON-1199
I just had a quick look at a possible fix, is anyone able to test the fix as suggested here?
http://issues.umbraco.org/issue/CON-1199#comment=67-43731
is working on a reply...