Can you use a partial view to insert a Contour form?
Hi
I have just started using Contour and the only way I found to insert and use a Contour form was to use an RTE field and choose insert the form macro. But surely there must be alternative method to insert och render Contour forms, aren'tthere?
When you have add Contour, then you can create a new data type under the data type folder, in the developer secton, and choose the form picker as the property editor. After that you can added it as a property to your document type, then you will get a list of forms, that can be choosen.
Currently there is a problem, where you can't unselect a form when it as been selected on a page.
You can also reference a form directly into a template, but this is mean that is "hard coded" by the GUID of the form. It look like this if you are using Umbraco 7 MVC:
@Umbraco.RenderMacro("umbracoContour.RazorRenderForm", new {FormGuid="9c2b4732-c9ab-4ea6-9ff8-aa684851d59f"})
I tried to use @Umbraco,RenderMacro but I got the error "Error loading MacroEngine script (file: MvcViewRenderContourForm.cshtml)", and looking in the log file, this was the output:
2014-11-07 22:56:23,652 [14] WARN umbraco.macro - [Thread 88] Error loading MacroEngine script (file: MvcViewRenderContourForm.cshtml, Type: ''. Exception: System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.WebPages.WebPageBase.CreateInstanceFromVirtualPath(String virtualPath, IVirtualPathFactory virtualPathFactory) at umbraco.MacroEngines.RazorMacroEngine.CompileAndInstantiate(String virtualPath) at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage) at umbraco.macro.loadMacroScript(MacroModel macro) at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId).
The same error also occurs when inserting the form macro in RTE, but I have no idea what is causing it. Perhaps you could point to any solution?
How did you insert your form into your template, did you just copy my code above?
Try go to a template in the settings section, choose a template and then click on the symbol for insert a macro, choose the insert form macro, and then you should get a list of your forms, that you could use. Choose a form and see if it goes better this time.
Yes that is what I did (so the FormGuid is correct). I found in a different forum topic that "Object reference not set to an instance of an object" may be cause by an issue regarding capital letters, e.g. an Id is converted to id somewhere in the underlying code, and thus it is not recognized correctly. I am running Umbraco 7.1.8 and Contour 3.0.23.
Can you use a partial view to insert a Contour form?
Hi
I have just started using Contour and the only way I found to insert and use a Contour form was to use an RTE field and choose insert the form macro. But surely there must be alternative method to insert och render Contour forms, aren'tthere?
Regards,
Martin
HI Martin,
When you have add Contour, then you can create a new data type under the data type folder, in the developer secton, and choose the form picker as the property editor. After that you can added it as a property to your document type, then you will get a list of forms, that can be choosen.
Currently there is a problem, where you can't unselect a form when it as been selected on a page.
Hope this helps,
/Dennis
Thanks for the advice Dennis!
Hi Martin,
I found the post, where I have seen the issue with the form picker http://our.umbraco.org/forum/umbraco-pro/contour/56349-Reset-form-picker-so-no-form-is-selected
You can also reference a form directly into a template, but this is mean that is "hard coded" by the GUID of the form. It look like this if you are using Umbraco 7 MVC:
/Dennis
Hi Martin,
I have created an issue on this, you can find it here and vote for it: http://issues.umbraco.org/issue/CON-616
/Dennis
I tried to use @Umbraco,RenderMacro but I got the error "Error loading MacroEngine script (file: MvcViewRenderContourForm.cshtml)", and looking in the log file, this was the output:
2014-11-07 22:56:23,652 [14] WARN umbraco.macro - [Thread 88] Error loading MacroEngine script (file: MvcViewRenderContourForm.cshtml, Type: ''. Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Web.WebPages.WebPageBase.CreateInstanceFromVirtualPath(String virtualPath, IVirtualPathFactory virtualPathFactory)
at umbraco.MacroEngines.RazorMacroEngine.CompileAndInstantiate(String virtualPath)
at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
at umbraco.macro.loadMacroScript(MacroModel macro)
at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId).
The same error also occurs when inserting the form macro in RTE, but I have no idea what is causing it. Perhaps you could point to any solution?
Thanks in advance,
Martin
Hi Martin,
How did you insert your form into your template, did you just copy my code above?
Try go to a template in the settings section, choose a template and then click on the symbol for insert a macro, choose the insert form macro, and then you should get a list of your forms, that you could use. Choose a form and see if it goes better this time.
Hope this helps,
/Dennis
Hi again,
Yes that is what I did (so the FormGuid is correct). I found in a different forum topic that "Object reference not set to an instance of an object" may be cause by an issue regarding capital letters, e.g. an Id is converted to id somewhere in the underlying code, and thus it is not recognized correctly. I am running Umbraco 7.1.8 and Contour 3.0.23.
Regards,
Martin
I now have solved it, it turned out that MvcViewRenderContourForm.cshtml was named incorrect, after changing to MvcRenderContourForm.cshtml it worked.
Martin
Hi Martin,
That is great to hear that you solved it.
/Dennis
is working on a reply...