Problems while rendering asynchronous form as plugin
As a developer I was updating an old Umbraco project to Umbraco 10. Since we are using USkinned block components for our new custom editors, I am building some components as App-Plugin, to keep supporting the older grit editors.
Currently I am stuck at rendering a Form in my editor.cshtml. Note that this is a plugin which does not access @Umbraco.
I tried several option and for now this one looks like the most obvious solution:
@await Component.InvokeAsync("RenderFormScripts", new { FormGuid = formGuid, FormTheme = string.Empty});
However, when awaiting this Invocation, I get an error message from the UDI parser: System.FormatException: String "17428" is not a valid udi.
I must asynchronically call the invocation, otherwise it shows the Task signature.
For now it looks like it tries to parse an nodeid which has nothing to do with the Form. The Form itself really exists with the proper GUID.
Does anybody know, where this id came from and how I can accomplish my goal?
Thanks for the reply! Indeed I was calling the RenderFormScript component with a valid FormGuid which is a valid GUID and not the nodeId. Thats the weird thing. I also tried it with the existing component: RenderFormScript
@await Component.InvokeAsync("RenderFormScripts", new { FormGuid = formGuid, FormTheme = string.Empty});
Also with a valid GUID which is available in the database. The result of the code above is that is always results in an error: System.InvalidOperationException: Cannot find form with Id 00000000-0000-0000-0000-000000000000
When debugging the code the GUID is in proper format and a valid form: {179f1720-c378-46bb-823d-51fbd6a138f0}
I have no clue how this can't work and why it results in an empty GUID.
and the RenderFormScripts component is called using the following
@await Component.InvokeAsync("RenderFormScripts", new { formId, theme = "default" })
rather than
@await Component.InvokeAsync("RenderFormScripts", new { FormGuid = formGuid, FormTheme = string.Empty});
So if you're setting your formGuid to the component parameter name FormGuid rather than not specifying the parameter name or setting it to formId, then it won't be setting your form guid to a parameter which exists in the component, which is probably why it's saying it's empty (00000000-0000-0000-0000-000000000000). Same with the FormTheme parameter as I think this might just be theme.
Thank for this replay. This solution gives me the exact same problems. However, I tried to debug a bit more and found out that I could use the UmbracoHelper and use a Marco by refering to it's alias. Next I got the problem that my helper was not instantiated with published content. Therefor I had to set AssignedContentItem with my current page publishedContent. Soo... for an app_plugin cshtml editor this is my current solution which works, also asynchronically:
Problems while rendering asynchronous form as plugin
As a developer I was updating an old Umbraco project to Umbraco 10. Since we are using USkinned block components for our new custom editors, I am building some components as App-Plugin, to keep supporting the older grit editors.
Currently I am stuck at rendering a Form in my editor.cshtml. Note that this is a plugin which does not access @Umbraco.
I tried several option and for now this one looks like the most obvious solution:
However, when awaiting this Invocation, I get an error message from the UDI parser: System.FormatException: String "17428" is not a valid udi.
I must asynchronically call the invocation, otherwise it shows the Task signature.
For now it looks like it tries to parse an nodeid which has nothing to do with the Form. The Form itself really exists with the proper GUID.
Does anybody know, where this id came from and how I can accomplish my goal?
So just to eliminate options, you're calling the RenderFormScripts component with the parameter FormGuid, is that parameter a GUID/Udi?
If so, what is the value of formGuid? Guessing it's 17428?
Thanks for the reply! Indeed I was calling the RenderFormScript component with a valid FormGuid which is a valid GUID and not the nodeId. Thats the weird thing. I also tried it with the existing component: RenderFormScript
Also with a valid GUID which is available in the database. The result of the code above is that is always results in an error: System.InvalidOperationException: Cannot find form with Id 00000000-0000-0000-0000-000000000000
When debugging the code the GUID is in proper format and a valid form: {179f1720-c378-46bb-823d-51fbd6a138f0}
I have no clue how this can't work and why it results in an empty GUID.
I'm wondering if it's the naming of the parameters that's causing the issue. Just had a look at
https://docs.umbraco.com/umbraco-forms/developer/rendering-scripts (granted it's the v11 docs)
and the RenderFormScripts component is called using the following
rather than
So if you're setting your formGuid to the component parameter name FormGuid rather than not specifying the parameter name or setting it to formId, then it won't be setting your form guid to a parameter which exists in the component, which is probably why it's saying it's empty (00000000-0000-0000-0000-000000000000). Same with the FormTheme parameter as I think this might just be theme.
Wonder if that might do the trick?
Thank for this replay. This solution gives me the exact same problems. However, I tried to debug a bit more and found out that I could use the UmbracoHelper and use a Marco by refering to it's alias. Next I got the problem that my helper was not instantiated with published content. Therefor I had to set AssignedContentItem with my current page publishedContent. Soo... for an app_plugin cshtml editor this is my current solution which works, also asynchronically:
is working on a reply...