Could not load form with id 00000000-0000-0000-000...
# help-with-umbraco
r
Version: Umbraco 12 We have an element that accepts a Form Selector and a Theme Selector. We then render it in a blocklist using the following syntax:
Copy code
@(await Component.InvokeAsync("RenderForm", new { formId = Model.Form, theme = Model.Theme, includeScripts = false }))
This does render the form as expected, however, when we submit it, we get the following error:
Copy code
System.InvalidOperationException: Could not load form with id 00000000-0000-0000-0000-000000000000
   at Umbraco.Forms.Web.Controllers.UmbracoFormsController.HandleForm(FormViewModel model)
   at lambda_method826(Closure, Object, Object[])
We've also tried the following syntax
Copy code
<umb-forms-render form-id="@Model.Form.Value" theme="@Model.Theme" exclude-scripts="false" />
This resulted in the same issue (displays fine, but fails on submission with the same error). When we use the macro inside the richtext editor, it works without issue. I've removed the only custom form workflow we had going to confirm that wasn't affecting anything. Any thoughts what else could cause this?
l
Looks like you’re setting formId to Model.Form, try Model.Form.Id?
r
You'd think that might be it, but Model.Form comes out as a GUID which is what it says its asking for (and that's how the documentation shows it). I also tried Model.Form.AsGuid() and that didn't help either. Plus, I know the Form ID portion is working because the form itself does load correctly, its just the postback that it freaks out.
l
How strange, I’m not sure on this one then! Hopefully someone else comes along and knows what is going on. Try installing a fresh version of Umbraco 12.x.x and seeing if you can replicate, if it works then it’s a game of spot the difference.
r
might be stuck having to go that route
Interesting update... This appears to be isolated to content rendered in partial views. Best guess at the moment is the viewstate/data isn't making it into that view so it knows what form to render on postback.
After more digging, we've found that if you want to use the form invokeasync inside of partials, its imporant to use the @Html.Partial syntax instead of . We aren't exactly sure why, but by simply changing it back to the older @Html.Partial, all of our issues went away.
65 Views