I have tried using the below in my .cshtml file by replacing the FormGuid with the contour form guid that I need. @Umbraco.RenderMacro("umbracoContour.RazorRenderForm", new{ FormGuid = "29e6a8df-71a2-45a0-aedd-9e0a114e87e2" })
I've got the below error: error CS0234: The type or namespace name 'RenderMacro' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)
Anything that I need to inherit before I can use the Umbraco.RenderMacro?
Is there an example/documentation of a Contour form running in an MVC rendered page.
I am using the RenderHelper from UmbracoHelper to render the RazorRenderForm but when I submit the form nothing happens.
I would be keen to know exactly what steps I am missing out on to get my form to submit and validate properly. Am I missing an HttpModule or something?
I have the form rendering fine through the Macro - I am just wondering what I need to do to get the form to 'work' so to speak. The form renders with this form tag markup.
<input name="__RequestVerificationToken" type="hidden" value="o0sTV6MwU/P8+tJImqYaxD9QleYZ5zDfZAGyWiOHY5LqWcNjk7qSiY8P7ROl9PwbUhrAtAeNSOw/Ys+c+QiposoK6Ags+YdIiSDrTRS2QaXbRtO8L/kDdSMaRLTP32+Pj56209IhIc6XMVDfGd4U8b1RLwhCrU5Heo2hgzbhyOumCqlcswtjv76bniErw+dL"><input data-val="true" data-val-number="The field FormStep must be a number." data-val-required="The FormStep field is required." id="FormStep" name="FormStep" type="hidden" value="1"><input data-val="true" data-val-required="The FormId field is required." id="FormId" name="FormId" type="hidden" value="04ce3316-0d8d-4e86-9eae-efd605b0b3d8"><input id="RecordId" name="RecordId" type="hidden" value=""><input data-val="true" data-val-required="The SubmitHandled field is required." id="SubmitHandled" name="SubmitHandled" type="hidden" value="False">
After doing a bit of debugging it seems when I submit the form I get an exception "A required anti-forgery token was not supplied or was invalid" here in the MvcRenderContourForm
Ok - looks like I am an idiot. I had a mix of 3.0.1 and 3.0.6 installed which was obviously causing a problem. I apologise for wasting your time Tim - thanks for looking into it anyway.
Still brings up the issue of logging though - as my issue did not log a thing. I think this is mostly Umbraco's issue with the macro renderer not logging exceptions however. I think there is a feature request for this coming up -hopefully in 6 with a decent loggin system we will see more logging creeping into the system.
... i have the parameter field defined okay on my doc type with an alias of formGuid, i have my form set on the content node, and if i display the "formGuid" variable [as defined in the MVC example cshtml] prior to the RenderMvCAction the variable is correctly set to my form's GUID
i'm running umbraco 4.7.2 / contour 3.0.0
Jeric said he'd fixed it, but he didn't say how :)
i see by reflection that this error is pushed out when the form is determined to be null, based on whether the form was loaded from FormStorage, but i can't see why it isn't...
When I insert a form in the rich text editor (Razor version) I get the "please provide a valid form id" message when I want to view the rendered form on the webpage.
I have tried reading through the above answers and I don't get what I should do to fix it. So could someone please tell me if this scenario is possible? And if so what should I specifically do in what file and how?
The FormGuid parameter exists on the macro - otherwise I would not have been able to select the macro from within the rich text editor. According to the documenation that is the only parameter that should be added, right?
Im basically stuck on the same problem.. I cant load my Form in my cshtml file. I have tried the answers above - but it keeps saying "Provide a valid form id" - I really cant figure out whats the trouble here. I can easily insert it on the template as Tim mentioned - and by that it works, however it isnt suitable for my current project to call the macro directly on the template - as it contains a lot of markup which is spliited into differenct macros already :-)
EDIT - i got it working by using the following in my cshtml file.
How to render the contour razor in a .cshtml file?
I've tried searching the forum but had found nothing on the topic.
I need to render the macro of a contour form in a .cshtml page.
thanks
Comment author was deleted
Hi Jeric,
Is this in mvc rendering mode? Then you'll need the syntax described in this post http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx
So
@Umbraco.RenderMacro(
"myMacroAlias"
,
new
{ name =
"Ned"
, age = 28 })
for a contour form this would be
@Umbraco.RenderMacro(
"umbracoContour.RazorRenderForm"
,
new
{ FormGuid =
"29e6a8df-71a2-45a0-aedd-9e0a114e87e2
"
})
Of course you'll need to correct form guid, that can be found on the settings tab of the form
If you are in webforms rendering mode you should be able to just use the insert macro button from the toolbar
I have tried using the below in my .cshtml file by replacing the FormGuid with the contour form guid that I need.
@Umbraco.RenderMacro(
"umbracoContour.RazorRenderForm"
,
new
{ FormGuid =
"29e6a8df-71a2-45a0-aedd-9e0a114e87e2
"
})
I've got the below error:
error CS0234: The type or namespace name 'RenderMacro' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)
Anything that I need to inherit before I can use the Umbraco.RenderMacro?
Comment author was deleted
Are you running in mvc rendering mode? So you have views and not master pages?
nop. it's umbraco 4.9
Just running web forms
Comment author was deleted
Check the MvcRenderContourForm.cshtml think you can just copy the contents of that and set a fixed formguid
I have tried that yesterday with the following:
@using Umbraco.Forms.Mvc.Bridge.Html;
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
string action = "ContourForm";
string controller = "FormRender";
string formtoken = "UmbracoContourForm";
string formGuid = "875fd3fb-a67e-4c44-afb1-197e69afb42d";
@Html.RenderMvcAction(action, controller, formGuid, formtoken, (umbraco.MacroEngines.DynamicNode)Model, (System.Dynamic.DynamicObject)Parameter);
}
But had been told the below:
Please provide a valid form Id
I've got the formGuid from my contour form but not sure why that it is not working.
Comment author was deleted
hmm that should work, will give it a test
Comment author was deleted
Yeah get the same result
It expect the formguid as a parameter, this should work:
Use that snippet above (from MvcRenderContourForm.cshtml)
then add a parameter with alias FormGuid of type form picker to your macro using your cshtml
any example on how the below should look like?
"then add a parameter with alias FormGuid of type form picker to your macro using your cshtml"
I'm quite new in this Razor / c# thing in umbraco.
Appreciate your help
thanks
Managed to get the parameter with alias FormGuid working. The form is loading too. Thanks
Comment author was deleted
Great :)
Hi,
Is there an example/documentation of a Contour form running in an MVC rendered page.
I am using the RenderHelper from UmbracoHelper to render the RazorRenderForm but when I submit the form nothing happens.
I would be keen to know exactly what steps I am missing out on to get my form to submit and validate properly. Am I missing an HttpModule or something?
cheers,
Robert
Comment author was deleted
@Robert you'll need to render the macro details on the syntax here http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx
I have the form rendering fine through the Macro - I am just wondering what I need to do to get the form to 'work' so to speak. The form renders with this form tag markup.
<form action="" enctype="multipart/form-data" method="post">
<input name="__RequestVerificationToken" type="hidden" value="o0sTV6MwU/P8+tJImqYaxD9QleYZ5zDfZAGyWiOHY5LqWcNjk7qSiY8P7ROl9PwbUhrAtAeNSOw/Ys+c+QiposoK6Ags+YdIiSDrTRS2QaXbRtO8L/kDdSMaRLTP32+Pj56209IhIc6XMVDfGd4U8b1RLwhCrU5Heo2hgzbhyOumCqlcswtjv76bniErw+dL"><input data-val="true" data-val-number="The field FormStep must be a number." data-val-required="The FormStep field is required." id="FormStep" name="FormStep" type="hidden" value="1"><input data-val="true" data-val-required="The FormId field is required." id="FormId" name="FormId" type="hidden" value="04ce3316-0d8d-4e86-9eae-efd605b0b3d8"><input id="RecordId" name="RecordId" type="hidden" value=""><input data-val="true" data-val-required="The SubmitHandled field is required." id="SubmitHandled" name="SubmitHandled" type="hidden" value="False">
After doing a bit of debugging it seems when I submit the form I get an exception "A required anti-forgery token was not supplied or was invalid" here in the MvcRenderContourForm
@Html.RenderMvcAction(action, controller, formGuid, formtoken, (umbraco.MacroEngines.DynamicNode)Model, (System.Dynamic.DynamicObject)Parameter);
Any ideas?
cheers,
Robert
OK,
Did some more digging. I think that Anti-forgery error was a bit of a red herring maybe as It was a first-chance exception.
Debugging the Model in the umbraco/plugins/contour/Form.cshtml file I can see that after submitting my Model.SubmitHandled is false.
Still no exception is raised or anything logged though.
Comment author was deleted
Did you chance anything to the form views or are they just the default one? It should just work then...
Comment author was deleted
Giving it a test now, reporting back with the different steps in a moment !
I haven't changed any of the umbraco razor files at all.
Comment author was deleted
Ok creating a test setup now, will report back in a minute
Comment author was deleted
Just tested and it worked fine...
1)Install umbraco with render engine set to Mvc (installed 6.0.0 RC)
2)Create a doctype with template
3)Create a content doc using that doctype
4)Install Contour
5)Create a form (created from the contact form template)
6)Populate the template with some simple html and insert the macro, looks like:
7) Going to frontend and submitting form
8)Viewing entries in Contour backoffice
All this worked fine...
Maybe you have an issue on your template, could you test with a simple template like this to see if that works?
Thanks,
Tim
Thanks Tim i will try it again tomorrow just with a blank site. I am using 4.11.3 though - should work for that right?
Comment author was deleted
Yeah should also work
Ok - looks like I am an idiot. I had a mix of 3.0.1 and 3.0.6 installed which was obviously causing a problem. I apologise for wasting your time Tim - thanks for looking into it anyway.
Still brings up the issue of logging though - as my issue did not log a thing. I think this is mostly Umbraco's issue with the macro renderer not logging exceptions however. I think there is a feature request for this coming up -hopefully in 6 with a decent loggin system we will see more logging creeping into the system.
OK,
So my forms were working nicely with 3.0.6.
Just upgraded to 3.0.7 and suddenly
Error loading MacroEngine script (file: MvcRenderContourForm.cshtml)
Couldn't get any more information out of it than that sadly.
Tried with a brand new installation of 4.11.4 as well to make sure it wasn't me doing something stupid again.
Has 3.0.7 broken compatibility with 4.11.x?
cheers,
Robert
Comment author was deleted
3.0.7 doesn't work with umb 4 it's for umb 6 sorry for the inconvience
Oh right thanks - might want to advertise that though.
Hi,
i'm having the same issue as Jeric was, namely:
"Please provide a valid form Id"
... i have the parameter field defined okay on my doc type with an alias of formGuid, i have my form set on the content node, and if i display the "formGuid" variable [as defined in the MVC example cshtml] prior to the RenderMvCAction the variable is correctly set to my form's GUID
i'm running umbraco 4.7.2 / contour 3.0.0
Jeric said he'd fixed it, but he didn't say how :)
i see by reflection that this error is pushed out when the form is determined to be null, based on whether the form was loaded from FormStorage, but i can't see why it isn't...
thanks!
@Martin Kerr and other potential troubleshooters having this problem in the future..
In your code, change the string:
to:
And then add the macro parameter with the type formPicker and the name formGuid in the macro, NOT in the razor file.
When this is done, just call your form GUID from your macro call, like:
<?UMBRACO_MACRO macroAlias="yourMacro" formGuid="insert-id-here"></?UMBRACO_MACRO>
Hi all
I have Umbraco 4.11 installed running webforms.
I have just installed Contour 3.012.
When I insert a form in the rich text editor (Razor version) I get the "please provide a valid form id" message when I want to view the rendered form on the webpage.
I have tried reading through the above answers and I don't get what I should do to fix it. So could someone please tell me if this scenario is possible? And if so what should I specifically do in what file and how?
Cheers,
Jan
Comment author was deleted
Hey Jan does it work when you place it on a template, just as a test?
Comment author was deleted
ANd yes it should be possible but looks like it's failing to pass the form id
Not sure how I would do that? Could you give me an example? :)
/Jan
Comment author was deleted
Well can you try to insert it on a template (just use the insert macro option) just to see if that works well
Hi Jan, as written in my latest answer, you have to make the form id a parameter to the macro.
Comment author was deleted
Ah yeah sounds like the macro wasn't created succesfully (so missing the form id param), check how to do this manually here http://our.umbraco.org/projects/umbraco-pro/contour/documentation/Installation/Manual (last part of the page)
The FormGuid parameter exists on the macro - otherwise I would not have been able to select the macro from within the rich text editor. According to the documenation that is the only parameter that should be added, right?
Comment author was deleted
Yup that's the only one, did you try it on a template yet, does that work ?
Ok, not sure what I did...but now it works...? :)
Case closed - will post if I at some point can recreate this again. Thanks for the help guys.
/Jan
Comment author was deleted
Yeah most have been an error in the form id somehow but glad it's working now :)
Im basically stuck on the same problem.. I cant load my Form in my cshtml file. I have tried the answers above - but it keeps saying "Provide a valid form id" - I really cant figure out whats the trouble here. I can easily insert it on the template as Tim mentioned - and by that it works, however it isnt suitable for my current project to call the macro directly on the template - as it contains a lot of markup which is spliited into differenct macros already :-)
EDIT - i got it working by using the following in my cshtml file.
@( Html.Raw(umbraco.library.RenderMacroContent("<?UMBRACO_MACRO formguid=\"6f2903fc-e27a-4d68-88d7-8d948746a6fe\" macroAlias=\"umbracoContour.RazorRenderForm\" ></?UMBRACO_MACRO>", Model.Id)))
Cheers,
Mikkel Toustrup
Comment author was deleted
Ok glad you got it working Mikkel :)
Or you could do it something similar to this, I'm using latest version of Contour and Umbraco Version 6.2.0 with UsiteBuilder
This is my Model
This is my view...
Simple, this works really well for me :-)
is working on a reply...